0

我正在使用 Modern 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" >
    <Controls:MetroWindow.Resources>
        <ContextMenu x:Key="MyContextMenu">
            <MenuItem Header="Send" />

        </ContextMenu>

    </Controls:MetroWindow.Resources>
    <Grid>
    </Grid>
</Controls:MetroWindow>

我正在尝试将上下文菜单添加到使用 Modern Metro UI 的 Wpf 应用程序

4

1 回答 1

4

上下文菜单应在实际元素中声明:

 <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>

于 2014-06-10T06:45:47.530 回答