Silverlight 从列表框项中删除焦点矩形
如何从silverlight列表框中删除焦点矩形?我有以下代码:Silverlight 从列表框项中删除焦点矩形,silverlight,silverlight-3.0,listbox,Silverlight,Silverlight 3.0,Listbox,如何从silverlight列表框中删除焦点矩形?我有以下代码: <ListBox x:Name="MyListBox" > <ListBox.ItemTemplate> <DataTemplate> <Grid > ...snipped... </Grid> </DataTemplate> <
<ListBox x:Name="MyListBox" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid >
...snipped...
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
我做错了什么?非常感谢:)在Silverlight中,
ListBoxItem
类型没有FocusVisualStyle
属性,因此出现错误
为了实现您的目标,您需要为ListBoxItem
提供一个新模板。从Silverlight文档中可以找到默认模板
将ListBoxItem模板复制到静态资源中(App.Xaml将是一个好地方)
System.Windows.Markup.XamlParseException: Invalid attribute value FocusVisualStyle for property Property. [Line: 47 Position: 38]
<ControlTemplate TargetType="ListBoxItem" x:Key="ListBoxItemSansFocus">
<!-- copy of the rest of the control template here -->
</ControlTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Template" Value="{StaticResource ListBoxItemSansFocus}" />
</Style>
</ListBox.ItemContainerStyle>