Skip to content

Commit

Permalink
Fix issue where SplitView overlay prevents clicking title bar buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Apr 24, 2020
1 parent 4284bc5 commit 93da03f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ModernWpf.Controls/SplitView/SplitView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ private void OnWindowPreviewMouseDown(object sender, MouseButtonEventArgs e)
}
}

if (e.OriginalSource is UIElement originalElement &&
TitleBarControl.GetInsideTitleBar(originalElement))
{
return;
}

if (IsPaneOpen)
{
e.Handled = true;
Expand Down
23 changes: 23 additions & 0 deletions ModernWpf/TitleBar/TitleBarControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public TitleBarControl()
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, MaximizeWindow));
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, RestoreWindow));
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, CloseWindow));

SetInsideTitleBar(this, true);
}

#region IsActive
Expand Down Expand Up @@ -294,6 +296,27 @@ public bool ExtendViewIntoTitleBar

#endregion

#region InsideTitleBar

internal static readonly DependencyProperty InsideTitleBarProperty =
DependencyProperty.RegisterAttached(
"InsideTitleBar",
typeof(bool),
typeof(TitleBarControl),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits));

internal static bool GetInsideTitleBar(UIElement element)
{
return (bool)element.GetValue(InsideTitleBarProperty);
}

internal static void SetInsideTitleBar(UIElement element, bool value)
{
element.SetValue(InsideTitleBarProperty, value);
}

#endregion

private Button BackButton { get; set; }

private FrameworkElement LeftSystemOverlay { get; set; }
Expand Down

0 comments on commit 93da03f

Please sign in to comment.