Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you set WindowChrome.IsHitTestVisibleInChrome in specific button programatically?

I have a custom title bar and I used WindowChrome.

In order to make the buttons clickable, I have to set WindowChrome.IsHitTestVisibleInChrome to true, that’s simple on xaml.

<Button x:Name="MyButton" WindowChrome.IsHitTestVisibleInChrome="true" />

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

However, how can I do the same programmatically?

By default, I have to set the WindowChrome.IsHitTestVisibleInChrome into false then it needs to be set to true later in the code.

I tried MyButton.IsHitTestVisible = true; but this doesn’t seem to work?

>Solution :

This is how you would set the WindowChrome.IsHitTestVisibleInChrome attached property of MyButton programmatically:

System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(MyButton, true);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading