diff --git a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml.cs b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml.cs index 57046181fd..d198fda0c0 100644 --- a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml.cs +++ b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml.cs @@ -438,7 +438,14 @@ private MetroWindow GetTestWindow() testWindow.Close(); } - testWindow = new MetroWindow() { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Title = "Another Test...", Width = 500, Height = 300 }; + testWindow = new MetroWindow() + { + Owner = this, + WindowStartupLocation = WindowStartupLocation.CenterOwner, + Title = "Another Test...", + Width = 500, + Height = 300 + }; testWindow.Closed += (o, args) => testWindow = null; return testWindow; } diff --git a/src/MahApps.Metro/Controls/ContentPresenterEx.cs b/src/MahApps.Metro/Controls/ContentPresenterEx.cs new file mode 100644 index 0000000000..8950e8c3da --- /dev/null +++ b/src/MahApps.Metro/Controls/ContentPresenterEx.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using ControlzEx.Windows.Shell; + +namespace MahApps.Metro.Controls +{ + public class ContentPresenterEx : ContentPresenter + { + static ContentPresenterEx() + { + ContentProperty.OverrideMetadata(typeof(ContentPresenterEx), new FrameworkPropertyMetadata(OnContentPropertyChanged)); + } + + private static void OnContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.OldValue is IInputElement && e.OldValue is DependencyObject oldInputElement) + { + BindingOperations.ClearBinding(oldInputElement, WindowChrome.IsHitTestVisibleInChromeProperty); + } + + if (e.NewValue is IInputElement && e.NewValue is DependencyObject newInputElement) + { + BindingOperations.SetBinding(newInputElement, WindowChrome.IsHitTestVisibleInChromeProperty, new Binding { Path = new PropertyPath(WindowChrome.IsHitTestVisibleInChromeProperty), Source = d }); + } + } + } +} \ No newline at end of file diff --git a/src/MahApps.Metro/Themes/MetroWindow.xaml b/src/MahApps.Metro/Themes/MetroWindow.xaml index f1c250dad5..c859022c6e 100644 --- a/src/MahApps.Metro/Themes/MetroWindow.xaml +++ b/src/MahApps.Metro/Themes/MetroWindow.xaml @@ -1,5 +1,6 @@  @@ -71,19 +72,21 @@ VerticalAlignment="Top" Focusable="False"> - + - + - + - + @@ -244,11 +251,19 @@ - + + + + + - - + + + + + + @@ -354,33 +369,36 @@ Panel.ZIndex="1" Focusable="False"> - + - + - + - + @@ -525,11 +546,19 @@ - + + + + + - - + + + + + +