【问题标题】:how to stop right click on TtitleBar in a WPF application如何在 WPF 应用程序中停止右键单击 TtitleBar
【发布时间】:2021-01-14 19:03:55
【问题描述】:

在 C# 中使用 WPF(使用 MahApps)编写程序并想知道如何禁用用户能够右键单击 TitleBar 并调出窗口选项菜单?

Edit1:确认我想保留栏上的最小/最大/关闭按钮,只需删除右键单击事件

【问题讨论】:

  • 这个问题有答案here
  • 链接答案的问题在于它也删除了控制框(最小/最大/关闭)。根据这个问题,我认为这不是理想的行为。
  • 正确的id喜欢保持最小/最大/关闭按钮只是删除右键事件

标签: c# wpf mahapps.metro


【解决方案1】:

MahApps v2.x 中有一个名为 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>

【讨论】:

  • 正是我想要的,谢谢,完美!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多