Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Listbox Selection Highlight

05 Jan 2015, 15:55

Hey everyone.
I'm using wpf listbox in our Unity3D project but having trouble styling it properly, selection highlight specifically.
I understand .net 4.5 made it harder to change it even in WPF and people are changing the whole listbox templates to do it but I wasn't able to make that work in noesis either.

https://www.dropbox.com/s/vz13z1nve9q8c ... s.JPG?dl=0
As you can see I'm getting those ugly listboxitem highlights around items.
So does anyone have any idea how to fix this?

thanks in advance
User avatar
Site Admin
Posts: 2538
Joined: 22 Dec 2011, 19:20

Re: Listbox Selection Highlight

05 Jan 2015, 16:59

ListBox selection appearance is defined by the ListBoxItem template. Our default style for ListBoxItem contains something like this:
<Style TargetType="{x:Type ListBoxItem}">
    <Setter Property="Template">
            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Trigger Property="IsSelected" Value="True">
                        <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PressBdBrush}"/>
                        <Setter TargetName="Border" Property="Background" Value="{StaticResource PressBgBrush}"/>
You can use IsSelected property to style your items accordingly.
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Re: Listbox Selection Highlight

06 Jan 2015, 10:42

Thanks sfernandez, it works perfectly.
I tried using custom controltemplate before but couldnt get it to work, probably forgot the IsSelected thing.

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 2 guests