Enable header action button hit-testing in window chrome

This commit is contained in:
Meik
2026-03-05 11:22:17 +01:00
parent 072e4a97e8
commit 9e4dab398f
2 changed files with 31 additions and 5 deletions

View File

@@ -353,18 +353,21 @@
HorizontalAlignment="Left"
Margin="14,14,0,0"
x:Name="Logo" />
<Border HorizontalAlignment="Right"
<Border x:Name="HeaderActionGroup"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,12,12,0"
Panel.ZIndex="500"
CornerRadius="10"
BorderThickness="1"
BorderBrush="{DynamicResource panelBorderColor}"
Background="{DynamicResource headerControlBackgroundColor}">
Background="{DynamicResource headerControlBackgroundColor}"
shell:WindowChrome.IsHitTestVisibleInChrome="True">
<StackPanel Orientation="Horizontal">
<Button x:Name="RefreshIcon"
Style="{StaticResource HeaderGroupButtonStyle}"
ToolTip="Refresh"
shell:WindowChrome.IsHitTestVisibleInChrome="True"
Click="OnRefreshButtonClick">
<Image Source="{DynamicResource nav_appbar_refresh}"
Tag="ICO"
@@ -377,6 +380,7 @@
<Button x:Name="Close_Text"
Style="{StaticResource HeaderGroupButtonStyle}"
ToolTip="{x:Static resx:Resources.close}"
shell:WindowChrome.IsHitTestVisibleInChrome="True"
Click="OnMinimizeButtonClick">
<TextBlock Text="X"
FontSize="15"

View File

@@ -1616,8 +1616,14 @@ namespace C4IT_CustomerPanel
private void GridTop_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.OriginalSource is DependencyObject source && FindVisualParent<Button>(source) != null)
return;
if (e.OriginalSource is DependencyObject source)
{
if (FindVisualParent<Button>(source) != null)
return;
if (FindVisualParent<Border>(source)?.Name == "HeaderActionGroup")
return;
}
if (e.ChangedButton == MouseButton.Left && ConfigSettings.GetConfig()._isDraggable)
this.DragMove();
@@ -1653,12 +1659,28 @@ namespace C4IT_CustomerPanel
if (source is T target)
return target;
source = VisualTreeHelper.GetParent(source);
source = GetParentObject(source);
}
return null;
}
private static DependencyObject GetParentObject(DependencyObject source)
{
if (source == null)
return null;
if (source is ContentElement contentElement)
{
DependencyObject parent = ContentOperations.GetParent(contentElement);
if (parent == null && contentElement is FrameworkContentElement frameworkContentElement)
parent = frameworkContentElement.Parent;
return parent;
}
return VisualTreeHelper.GetParent(source);
}
private void App_KeyDown(object sender, KeyEventArgs e)
{
if (((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) && Keyboard.IsKeyDown(Key.R) && ConfigSettings.GetConfig()._isDraggable)