我有一个已经在Windows 7及以下针对.NET框架4高兴地运行的应用程序。 如果应用程序已经安装在Windows 8中(运行.NET 4.5,但仍针对.NET 4中),它显示一个蓝色的背景在一个列表框或组合框和一个白色背景的焦点项目所选项目。反正有没有删除此? 我用我的XAML以下设置样式有问题这似乎Windows 8的前解决这个问题。
< ListBox.ItemContainerStyle>
<风格的TargetType ={X:输入一个ListBoxItem}>
< setter属性=FocusVisualStyleVALUE ={X:空}/>
< Style.Resources>
<的SolidColorBrush X:关键={X:静态SystemColors.HighlightBrushKey}颜色=透明/>
<的SolidColorBrush X:关键={X:静态SystemColors.ControlBrushKey}颜色=透明/>
< /Style.Resources>
< /样式和GT;
< /ListBox.ItemContainerStyle>
解决方案
我忘了,回来跟我是如何解决这个....原来,所有你需要做的是创建一个空白项容器样式并将其分配给您的列表框/组合框等....你可以使用这个问题,以及让你可以使用诸如列表框样式={的StaticResource CurrentStyle}现在的风格ItemContainerStyle ={的StaticResource BlankListBoxContainerStyle}/>其中BlankListBoxContainerStyle会是像.....
<风格X:关键=BlankListBoxContainerStyle的TargetType ={X:输入一个ListBoxItem}>
< setter属性=模板>
< Setter.Value>
<的ControlTemplate的TargetType ={X:输入一个ListBoxItem}>
<内容presenter的HorizontalAlignment ={TemplateBinding HorizontalContentAlignment}SnapsToDevicePixels ={TemplateBinding SnapsToDevicePixels}VerticalAlignment ={TemplateBinding VerticalContentAlignment}/>
< /控件模板>
< /Setter.Value>
< /二传手>
< setter属性=FocusVisualStyle
值={X:空}/>
< /样式和GT;
I have an application that's been running happily on windows 7 and below targeting the .net 4 framework. If the application is now installed in windows 8 (Running .net 4.5 but still targeting .net 4) it shows a blue background for a selected item in a listbox or combobox and a white background for a focused item. Is there anyway to remove this? I'm using the following in my XAML to set the style in question which seemed to resolve the issue before windows 8.
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
</Style.Resources>
</Style>
</ListBox.ItemContainerStyle>
解决方案
I forgot to come back with how I solved this.... Turns out that all you need to do it create a blank Item Container Style and assign it to your listbox/combobox etc.... You can use this as well as keeping the current style you may be using such as ListBox Style="{StaticResource CurrentStyle}" ItemContainerStyle="{StaticResource BlankListBoxContainerStyle}" /> Where BlankListBoxContainerStyle would be something like.....
<Style x:Key="BlankListBoxContainerStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="FocusVisualStyle"
Value="{x:Null}"/>
</Style>