- golgepapaz
- Posts: 43
- Joined:
Listbox Selection Highlight
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
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
-
sfernandez
Site Admin
- Posts: 3107
- Joined:
Re: Listbox Selection Highlight
ListBox selection appearance is defined by the ListBoxItem template. Our default style for ListBoxItem contains something like this:
You can use IsSelected property to style your items accordingly.
Code: Select all
<Style TargetType="{x:Type ListBoxItem}">
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
...
<ControlTemplate.Triggers>
...
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PressBdBrush}"/>
<Setter TargetName="Border" Property="Background" Value="{StaticResource PressBgBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
- golgepapaz
- Posts: 43
- Joined:
Re: Listbox Selection Highlight
Thanks sfernandez, it works perfectly.
I tried using custom controltemplate before but couldnt get it to work, probably forgot the IsSelected thing.
Cheers.
I tried using custom controltemplate before but couldnt get it to work, probably forgot the IsSelected thing.
Cheers.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 16 guests