1

Writing a program using WPF (with MahApps) In C# and wondering how can I disable a user being able to right click the TitleBar and brining up the window options menu?

Edit1: to confirm I would like to keep the min/max/close button on the bar, just remove the right click event

  • There's an answer to this question [here](https://stackoverflow.com/a/20963907/14956277). – D M Jan 14 '21 at 19:18
  • The problem with that linked answer is that it removes the control box as well (min/max/close). Based on the question, I don't think that's the desired behavior. – Jason Tyler Jan 14 '21 at 19:52
  • correct id like to keept the min/max/close button just remove the right click event – Harrison O'Donnell Jan 14 '21 at 20:56

1 Answers1

2

There is a new property in MahApps v2.x called ShowSystemMenuOnRightClick.

<mah:MetroWindow x:Class="MetroDemo.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 Title="MahApps.Metro - Demo Application"
                 Width="900"
                 Height="600"
                 mah:DialogParticipation.Register="{Binding}"
                 GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
                 ShowIconOnTitleBar="True"

                 ShowSystemMenuOnRightClick="False"

                 WindowStartupLocation="CenterScreen"
                 mc:Ignorable="d">

</mah:MetroWindow>
punker76
  • 14,326
  • 5
  • 58
  • 96