Remove ListBoxItem Highlighting

A Silverlight/Wpf ListBoxItem is highlighted when selected or when the mouse hovers over it.

I need to display a list of items that are not highlighted when selected. This is a common scenario when displaying an inactive list for simply listing out some information.

ListBoxItem’s default template can be easily inspected and modified using Expression Blend – Select a ListBoxItem in Objects and Timeline pane, Right click and select Edit template > Edit a Copy. Name you template and save it at the scope of your choice.

This will create a copy of the template and allow you to modify it. Switch to the xaml view. Locate the VisualStates of MouseOver, Selected and Focused, and blank them out –

de-highlighted-xaml

The style is applied to the ListBoxItems using ItemContainerStyle –

applying-style-to-listboxitems

Here is the xaml style for the ListBoxItem –

After the style is applied, the ListBoxItems are not highlighted when selected or focused. Here is a live demo of a ListBox that does not highlight when items are selected : remove-listboxitem-hlighting-demo

Should you get into Silverlight or Flash ?

Take a look at these trend lines from Indeed.com (Yes, you read that right. That is EIGHTY THOUSAND percent growth in silverlight jobs) –
Here is the trend line for Flash jobs –
Growth is there but the total number of jobs are clearly stabilizing. Here are the absolute number of jobs –
Interesting numbers !!!

RIA with Silverlight and WCF – Los Angeles .NET Developers Group

 

I will be attending Jason Beres’ “RIA with Silverlight and WCF” lecture on Saturday the 4th. Check-out the details here : Los Angeles .NET Developers Group. Let me know If you are planning to be there. It will be a great opportunity to meet.