White frame around listbox Item selection on Windows8 White frame around listbox Item selection on Windows8 wpf wpf

White frame around listbox Item selection on Windows8


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.


i think this may be helpful for you. use Trigger property for isSelected.

 <ListBox Name="lst">    <ListBox.ItemContainerStyle>        <Style TargetType="ListBoxItem">            <Style.Triggers>                <Trigger Property="IsSelected" Value="True" >                    <Setter Property="BorderBrush" Value="Wheat"/>                    <Setter Property="BorderThickness" Value="0"/>                  </Trigger>            </Style.Triggers>        </Style>    </ListBox.ItemContainerStyle></ListBox>


Yes, the last answer really helps.This is how I get rid of the white frames around ListBoxItem:

        <ListBox.ItemContainerStyle>            <Style TargetType="ListBoxItem">                <Style.Setters>                    <Setter Property="BorderBrush" Value="Gray"/>                    <Setter Property="BorderThickness" Value="0,0,0,1"/>                    <Setter Property="Padding" Value="0"/>                    <Setter Property="Background" Value="Black"/>                </Style.Setters>            </Style>        </ListBox.ItemContainerStyle>        <ListBox.ItemsPanel>            <ItemsPanelTemplate>                <StackPanel Background="Black"/>            </ItemsPanelTemplate>        </ListBox.ItemsPanel>