在ContextMenu中使用MahApps图标
我正在使用MahApps Metro UI工具包编写WPF应用程序。
http://mahapps.com/guides/quick-start.html
从他们网站上的指南,我基本完成了我的应用程序,它看起来很光滑。 我唯一的问题是我无法找到如何使用他们提供的图标包作为contextmenu图标。
这是我正在尝试做的一个直观的例子。 虽然我能够获得原始的“Windows”菜单项来显示它的图标,但我无法对上下文菜单项执行相同的操作。 有什么我做错了或解决这个问题的方法吗?
这是我的.xaml:
我的.xaml.cs:
public partial class MainWindow { public MainWindow() { InitializeComponent(); DataContext = new MainWindowViewModel(); } private void WindowsMenuItem_Click(object sender, RoutedEventArgs e) { (sender as MenuItem).ContextMenu.IsEnabled = true; (sender as MenuItem).ContextMenu.PlacementTarget = (sender as MenuItem); (sender as MenuItem).ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; (sender as MenuItem).ContextMenu.IsOpen = true; } }
我使用以下方法在我的应用程序中工作:
...