如何以编程方式在特定按钮中设置 WindowChrome.IsHitTestVisibleInChrome?
How do you set WindowChrome.IsHitTestVisibleInChrome in specific button programatically?
我有一个自定义标题栏并且我使用了 WindowChrome。
为了使按钮可点击,我必须将 WindowChrome.IsHitTestVisibleInChrome
设置为 true
,这在 xaml 上很简单。
<Button x:Name="MyButton" WindowChrome.IsHitTestVisibleInChrome="true" />
但是,我如何以编程方式执行相同的操作?
默认情况下,我必须将 WindowChrome.IsHitTestVisibleInChrome
设置为 false
然后需要稍后在代码中将其设置为 true。
我尝试了 MyButton.IsHitTestVisible = true;
但这似乎不起作用?
这就是如何以编程方式设置 MyButton
的 WindowChrome.IsHitTestVisibleInChrome
附加 属性:
System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(MyButton, true);
我有一个自定义标题栏并且我使用了 WindowChrome。
为了使按钮可点击,我必须将 WindowChrome.IsHitTestVisibleInChrome
设置为 true
,这在 xaml 上很简单。
<Button x:Name="MyButton" WindowChrome.IsHitTestVisibleInChrome="true" />
但是,我如何以编程方式执行相同的操作?
默认情况下,我必须将 WindowChrome.IsHitTestVisibleInChrome
设置为 false
然后需要稍后在代码中将其设置为 true。
我尝试了 MyButton.IsHitTestVisible = true;
但这似乎不起作用?
这就是如何以编程方式设置 MyButton
的 WindowChrome.IsHitTestVisibleInChrome
附加 属性:
System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(MyButton, true);