如何在现代Metro UI的wpf中添加上下文菜单
我正在做一个wpf应用程序使用现代地铁用户界面,我想在这个应用程序上下文菜单 我尽力了如何在现代Metro UI的wpf中添加上下文菜单,wpf,modern-ui,Wpf,Modern Ui,我正在做一个wpf应用程序使用现代地铁用户界面,我想在这个应用程序上下文菜单 我尽力了 <Controls:MetroWindow x:Class="Something" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Controls:MetroWindow x:Class="Something" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title=""
Width="326.478"
Height="5" ShowIconOnTitleBar="True" ShowTitleBar="True"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d" ResizeMode="CanMinimize" Loaded="MetroWindow_Loaded" >
<Controls:MetroWindow.Resources>
<ContextMenu x:Key="MyContextMenu">
<MenuItem Header="Send" />
</ContextMenu>
</Controls:MetroWindow.Resources>
<Grid>
</Grid>
</Controls:MetroWindow>
我正在尝试将上下文菜单添加到使用现代Metro UI的Wpf应用程序中上下文菜单应在实际元素中声明:
<Controls:MetroWindow x:Class="Something" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title=""
Width="326.478"
Height="5" ShowIconOnTitleBar="True" ShowTitleBar="True"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d" ResizeMode="CanMinimize" Loaded="MetroWindow_Loaded" >
<Grid>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>
上下文菜单应在实际元素中声明:
<Controls:MetroWindow x:Class="Something" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title=""
Width="326.478"
Height="5" ShowIconOnTitleBar="True" ShowTitleBar="True"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
mc:Ignorable="d" ResizeMode="CanMinimize" Loaded="MetroWindow_Loaded" >
<Grid>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" />
</ContextMenu>
</Grid.ContextMenu>
</Grid>
谢谢,它起作用了!我可以从代码中添加此上下文菜单吗?正如,如果我想在菜单上设置标题动态或取决于某些条件,您可以使用事件,或尝试使用解释的方法进行数据绑定。谢谢,它正在工作!我可以从代码中添加此上下文菜单吗?例如,如果我想在菜单动态上设置标题,或者取决于某些条件,您可以使用事件,或者尝试使用所解释的方法进行数据绑定