When a user clicks on a ListBoxItem, I want to make it a bold big font red background yellow
Everything works except the background It seems that there is a standard (blue) background for the selected item. How can I override it and change the selected background?
Here is the code:
& lt; Window x: orbit = "optional": //schemas.microsoft.com/winfx/2006/xaml/presentation "xmlns: x =" http://schemas.microsoft.com/winfx/2006/xaml "title =" window 1 "height =" 300 "width =" 300 "xmlns: local =" clr-namespace: Alternate list box 2 "> gt; Resources. · Local: country x: key =" country " /> Style TargetType = "{x: Type ListboxItem}" & gt; Setter property = "content" value = "{binding path = name}" /> gt; Setter property = "Margin" value = "2" /> gt; Style.Triggers & gt; Trigger Property = "Iced" value = "true"> gt; Setter property = "font size" value = "18" /> gt; Setter property = "background" value = "yellow" /> & lt; setter Property = "foreground" value = "red" /> gt; / catalyst & gt; & gt; /style.Triggers> & gt; Style & gt; & lt; /Window.Resources> & gt; StackPanel & Gt; ListBox ItemsSource = "{Binding Source = {Static Resources Country}}" width = "100" margin = "10" horizontal align = "left" /> & Lt; / StackPanel & gt; & Lt; / Window & gt;
It can be very simplified taken from the SystemColors background color for the selected ListBox items So, what you have to do, override SystemColors in your listbox resources:
& Lt ;! - The selected color when the listbox is not centered - & gt; & Lt; Solid Coiler Brush x: Key = "{x: Static System Calculators.ControlBrisk}" color = "yellow" /> & Lt; /ListBox.Resources>
Comments
Post a Comment