-1

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?

  • Does this answer your question? [How to set an attached property programmatically eg. Viewport2DVisual3D.IsVisualHostMaterialProperty](https://stackoverflow.com/questions/24571504/how-to-set-an-attached-property-programmatically-eg-viewport2dvisual3d-isvisual) – Selvin Apr 20 '22 at 13:35

1 Answers1

1

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

System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(MyButton, true);
mm8
  • 163,881
  • 10
  • 57
  • 88