Removing the Dotted border around selected WPF UI element

消除WPF默认选择样式

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值