I am getting complaints from Windows8
users about a strange frame around the SelectedItem
on ListBoxes
In Windows7
this issue does not exists and so far I have found no way to get rid of this white frame.
As far as I can tell Windows8
listboxes now use ControlBrushKey
instead of HighlightBrushKey
but setting that to Transparent
has no affect.
I have no Windows8 development environment at the moment so all fixes I have tried are pure guess work.
ListBox Resources:
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent" />
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
</ListBox.Resources>
The entire Xaml can be found here: https://github.com/saddam213/MPDisplay/blob/master/GUIFramework/GUI/Controls/GUIList.xaml
Image of the frame: (white box around selection)
If anyone has a clue how to get rid of this it would be great.
In a comment in your original post, you said:
I am not going to rebuild a control just because of a brush that needs to be overridden, I just will not support Windows8 if I need to override a entire ListBox template to remove a selection color, it will be simple once I install Win8 to find the brush using snoop
However, it is not painfully difficult to "rebuild" the ListBoxItem
. It may, in fact, be simpler than forcing brushes, as you do not need to worry about overriding every UX change between Windows versions. One particular app I am building right now has the requirement that it run on every OS from XP to 8.1; I achieved a uniform look across all OSes by customizing everything down to the window borders.
Your best bet would be to style every aspect of the ListBoxItem
by creating a template, something like the following:
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Blue" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Obviously, you would need to modify the styles to get the exact behavior you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With