Welcome to WindowsClient.net | Sign in | Join
in

WindowsClient.net

Learnings..

Removing the Dotted border around selected WPF UI element

The WPF app i have been working on looks great but there was a small visual irritant which i wasn't being able to get rid of. Everytime i clicked on a UI element..especially a ListViewItem, treeViewitem it would have this default selected look i.e a Blue background with a dotted boundary.Also the default selected look varies depending on the Theme of the OS.

This Blue Background when selected is defined in the Control Template of the element under the Triggers section and can be commented out/ modified to change the default look.You can even force WPF to use a specific theme irrespective of the OS its working on .Hopefully i will be putting in another entry on how to overwrite the default theme of the OS if you want your app to look consisten across say Vista and Server 2003.

 My problem was the dotted line around the selected item. This would appear in buttons, treeview items, list view items..almost everywhere.

It took me very long and a lot of trial and error to figure out the property responsible for this dotted line.The property is "FocusVisualStyle". You need to set it to {x:Null} to get rid of that evil dotted line.

 <ListViewItem Content="ListViewItem" FocusVisualStyle= "{x:Null}" />

So if you are trying to get a smooth look which selecting your items in a Server 2003 environment

FocusVisualStyle="{x:Null}" is the key!!

Next in queue:-Getting rid of the default blue selected look and forcing WPF app to use a specific theme!!

Until next time..

anshulee

Comments

 

boomhauer said:

ever figure out the blue selection thing? i want to get rid of this in the list of options under a combo box... the blue that is ;)

May 30, 2008 12:01 AM
 

Johan said:

Hi there did you find away to remove the blue selection thing?

November 23, 2008 12:08 PM
 

Anshulee said:

November 25, 2008 8:09 AM

Leave a Comment

(required)  
(optional)
(required)  
Add
Page view counter