feat: Properly handle nc hit test for caption buttons. (#745)

This commit is contained in:
Zhang Dian
2026-02-09 21:33:12 +08:00
committed by GitHub
parent 3b0b007a40
commit fdbfd91b8f
2 changed files with 19 additions and 5 deletions

View File

@@ -50,21 +50,33 @@
Data="{StaticResource WindowExpandGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
<Button Name="PART_MinimizeButton" Theme="{StaticResource CaptionButton}">
<Button
Name="PART_MinimizeButton"
Theme="{StaticResource CaptionButton}"
AutomationProperties.Name="Minimize"
Win32Properties.NonClientHitTestResult="MinButton">
<PathIcon
Name="PART_MinimizeButtonIcon"
Theme="{StaticResource InnerPathIcon}"
Data="{StaticResource WindowMinimizeGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
<Button Name="PART_RestoreButton" Theme="{StaticResource CaptionButton}">
<Button
Name="PART_RestoreButton"
Theme="{StaticResource CaptionButton}"
AutomationProperties.Name="Maximize"
Win32Properties.NonClientHitTestResult="MaxButton">
<PathIcon
Name="PART_RestoreButtonIcon"
Theme="{StaticResource InnerPathIcon}"
Data="{StaticResource WindowMaximizeGlyph}"
Foreground="{Binding $parent[Button].Foreground}" />
</Button>
<Button Name="PART_CloseButton" Theme="{StaticResource CaptionButton}">
<Button
Name="PART_CloseButton"
Theme="{StaticResource CaptionButton}"
AutomationProperties.Name="Close"
Win32Properties.NonClientHitTestResult="Close">
<PathIcon
Name="PART_CloseButtonIcon"
Theme="{StaticResource InnerPathIcon}"

View File

@@ -16,12 +16,14 @@
<Border
Name="PART_Background"
Background="{TemplateBinding Background}"
IsHitTestVisible="False" />
IsHitTestVisible="False"
Win32Properties.NonClientHitTestResult="Caption" />
<CaptionButtons
Name="PART_CaptionButtons"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Foreground="{TemplateBinding Foreground}" />
Foreground="{TemplateBinding Foreground}"
Win32Properties.NonClientHitTestResult="Client" />
</Panel>
</Panel>
</ControlTemplate>