views:

343

answers:

1

Hi I am using Listbox with ItemTemplate, and when I select an item from the list, it shows blue background How can I style the selected item, to be similar to non-selected one?

+1  A: 

I hope you are looking for to remove the blue default ListBox selection. That color is coming from the IsSelected DataTrigger on the ListBoxItem style. You can override that by creating a copy of ListBoxItemStyle, which is ListBox.ItemContainerStyle

Just a little more inside information about a ListBox customization. Basically a ListBox customization includes overriding below styles and templates

  • ListBox.Style - if you want to change the Way the outer shell looks and feel
  • ListBox.ItemTemplate - Set the appropriate DataTemplate to display the Individual properties of a type T, where ListBox.ItemsSource is bind to IEnumerable
  • ListBox.ItemsPanel - Set the ItemsPanelTemplate which contains a Panel so that the items get laid out by the panel. By default it is a StackPanel with orientation is vertical.
  • ListBox.ItemContainerStyle - set the style of the ListBoxItem
Jobi Joy