Skip to content

Commit

Permalink
Merge pull request #3482 from MahApps/feature/GH-3453-ShowSystemMenu
Browse files Browse the repository at this point in the history
(GH-3453) Add new property ShowSystemMenu
  • Loading branch information
punker76 committed Apr 9, 2019
2 parents a1c0938 + e395b8d commit a3a8db8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml
Expand Up @@ -227,6 +227,13 @@
Header="Window icon: no scale, smaller frame"
IsCheckable="True"
IsChecked="{Binding IsNoScaleSmallerFrame, Mode=OneWay}" />
<Separator />
<MenuItem Header="ShowSystemMenu"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}, Path=ShowSystemMenu}" />
<MenuItem Header="ShowSystemMenuOnRightClick"
IsCheckable="True"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}, Path=ShowSystemMenuOnRightClick}" />
</MenuItem>
</Menu>

Expand Down
14 changes: 12 additions & 2 deletions src/MahApps.Metro/Controls/MetroWindow.cs
Expand Up @@ -84,6 +84,7 @@ public class MetroWindow : Window
/// </summary>
public static readonly DependencyProperty IsCloseButtonEnabledWithDialogProperty = IsCloseButtonEnabledWithDialogPropertyKey.DependencyProperty;

public static readonly DependencyProperty ShowSystemMenuProperty = DependencyProperty.Register("ShowSystemMenu", typeof(bool), typeof(MetroWindow), new PropertyMetadata(true));
public static readonly DependencyProperty ShowSystemMenuOnRightClickProperty = DependencyProperty.Register("ShowSystemMenuOnRightClick", typeof(bool), typeof(MetroWindow), new PropertyMetadata(true));

public static readonly DependencyProperty TitleBarHeightProperty = DependencyProperty.Register("TitleBarHeight", typeof(int), typeof(MetroWindow), new PropertyMetadata(30, TitleBarHeightPropertyChangedCallback));
Expand Down Expand Up @@ -549,7 +550,16 @@ public bool IsCloseButtonEnabledWithDialog
}

/// <summary>
/// Gets/sets if the the system menu should popup on right click.
/// Gets or sets a value that indicates whether the system menu should popup with left mouse click on the window icon.
/// </summary>
public bool ShowSystemMenu
{
get { return (bool)GetValue(ShowSystemMenuProperty); }
set { SetValue(ShowSystemMenuProperty, value); }
}

/// <summary>
/// Gets or sets a value that indicates whether the system menu should popup with right mouse click if the mouse position is on title bar or on the entire window if it has no title bar (and no title bar height).
/// </summary>
public bool ShowSystemMenuOnRightClick
{
Expand Down Expand Up @@ -1307,7 +1317,7 @@ private void IconMouseDown(object sender, MouseButtonEventArgs e)
{
Close();
}
else
else if (this.ShowSystemMenu)
{
ShowSystemMenuPhysicalCoordinates(this, PointToScreen(new Point(0, TitleBarHeight)));
}
Expand Down

0 comments on commit a3a8db8

Please sign in to comment.