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

Time:04-20

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" />

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?

CodePudding user response:

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

System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(MyButton, true);
  • Related