This example customizes shape context menus within the DevExpress WPF Diagram Control.
The Diagram Control does not include built-in APIs to customize shape-related context menus. You can create a DiagramControl
or DiagramDesignerControl
class descendant and override the CreateContextMenu or CreateContextToolBar method to add custom menu items as needs dictate:
public class DiagramDesignerControlEx : DiagramDesignerControl {
protected override IEnumerable<IBarManagerControllerAction> CreateContextToolBar() {
if (SelectedItems != null && SelectedItems.Count > 0) {
var item = new BarButtonItem() {
Glyph = DXImageHelper.GetImageSource("Images/Arrows/Stop_16x16.png"),
};
item.ItemClick += OnContextToolBarItemClick;
yield return item;
}
foreach (IBarManagerControllerAction action in base.CreateContextMenu())
yield return action;
}
protected override IEnumerable<IBarManagerControllerAction> CreateContextMenu() {
if (SelectedItems != null && SelectedItems.Count > 0) {
var item = new BarButtonItem() {
Glyph = DXImageHelper.GetImageSource("Images/Arrows/Record_16x16.png"),
Content = "Custom Item"
};
item.ItemClick += OnContextMenuItemClick;
yield return item;
}
foreach (IBarManagerControllerAction action in base.CreateContextMenu())
yield return action;
}
}
(you will be redirected to DevExpress.com to submit your response)