Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove (avoid) focus in WPF

I want to avoid focus coming on wpf Grid for that I have tried:

<Grid Focusable="False" />

but it is not working. I also tried with:

<Grid x:Name="Grid" Focusable="False" FocusVisualStyle="{x:Null}" />

but I again failed. How can I avoid focus coming on Grid?

like image 460
Rudresh Bhatt Avatar asked Mar 22 '23 02:03

Rudresh Bhatt


1 Answers

ContentControl has a default Focusable="True", because Control base class overrides the metadata of the Focusable property and sets its default to true - MSDN.

Just set the value to false:

<ContentControl Focusable="False" />

To keep track of where it comes focus, Snoop a wonderful program. In it, you can find the source of focus.

like image 166
Anatoliy Nikolaev Avatar answered Apr 06 '23 14:04

Anatoliy Nikolaev