Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-3453) Add new property ShowSystemMenu #3482

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/MahApps.Metro.Samples/MahApps.Metro.Demo/MainWindow.xaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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