How do you change the style of the SelectedItem in a ListBox Control By default it puts a dark blue background behind the item and changes the text to white in order for the text to stand out. Where does this behavior come from and how can you change it For example I'd like to change the color it uses as a background and the color it makes the text.
-Ryan

Changing the Style of the SelectedItem in a ListBox
Mohan1
if you add this style in window/page,this will be applicable to window. you can add it in App.xaml in resources section so it wll be applicable to all window(s)/page(s) in the application
<
Application.Resources>...
</Application.Resources>
AndyMauer
Most of my work using VB.Net and ASP.Net has been on the code behind side and not on the html end. I need to do exactly the same thing. Where do I insert the code snippet to make this work Is there a way to stick it into web.config or somewthing like that to make it global to the whole web site Thanks.
Dhanya Ajith
change the controltemplate
ms-help://MS.MSSDK.1033/MS.NETFX30SDK.1033/wpf_conceptual/html/964e3117-b759-47c0-b478-005d6ba2c6b9.htm
johnof
Code snippet: changing the selected ListBoxItem background color.
<Window.Resources><
Style TargetType="{x:Type ListBoxItem}"><
Setter Property="Template"><
Setter.Value><
ControlTemplate TargetType="{x:Type ListBoxItem}"><
TextBlock Name="TheBGControl"><ContentPresenter /></TextBlock><
ControlTemplate.Triggers><
Trigger Property="IsSelected" Value="True"><
Setter Property="Background" Value="Red" TargetName="TheBGControl" /></
Trigger></
ControlTemplate.Triggers></
ControlTemplate></
Setter.Value></
Setter></
Style></
Window.Resources><
Grid><
ListBox><
ListBoxItem>Item 1</ListBoxItem><
ListBoxItem>Item 2</ListBoxItem></
ListBox></
Grid>