Hello,
I need to create a context menu, is it possible to do this using the VS 2010 designer / see a preview while writing your xaml code? Thanks for any hint!
Hello,
I need to create a context menu, is it possible to do this using the VS 2010 designer / see a preview while writing your xaml code? Thanks for any hint!
I dont use VS Designer view. I always prefer to write my XAML myself. ContextMenu is very easy to create. You just need to create a contextmenu as staticResource or directly into the property contextmenu.
<ContextMenu>
<MenuItem Command="Cut">
<MenuItem.Icon>
<Image Source="Images/cut.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="Copy">
<MenuItem.Icon>
<Image Source="Images/copy.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="Paste">
<MenuItem.Icon>
<Image Source="Images/paste.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
You can also create contextmenu dynamically using code.
MenuItem mnu = new MenuItem();
mnu.Header = "Paste";
contextmenu.Items.Add(mnu);
I hope this will help you.
I'm not sure about WPF/XAML, but in WinForms you can drag a ContextMenu onto the designer to edit it. Look for the ContextMenu in your Toolbox.