wpf-devexpress-dot-xpf-dot-editors-dot-imageedittoeditmodebehavior.md
Allows you to change items displayed in the ImageEdit edit menu.
Namespace : DevExpress.Xpf.Editors
Assembly : DevExpress.Xpf.Core.v25.2.dll
NuGet Package : DevExpress.Wpf.Core
public event EventHandler<CustomEditMenuItemsEventArgs> CustomEditMenuItems
Public Event CustomEditMenuItems As EventHandler(Of CustomEditMenuItemsEventArgs)
The CustomEditMenuItems event's data class is CustomEditMenuItemsEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| EditMenuItems | Gets or sets a collection of items displayed in the ImageEdit edit menu. |
The CustomEditMenuItems event occurs when the editor is displayed (if ShowMenuMode is set to Always) or each time the edit menu is shown (if ShowMenuMode is set to Hover). This event allows you to add and remove buttons.
The following code sample removes zoom-related buttons ( Zoom In and Zoom Out ) and adds confirmation buttons ( OK and Cancel ):
void editBehavior_CustomEditMenuItems(object sender, DevExpress.Xpf.Editors.CustomEditMenuItemsEventArgs e) {
// Remove Zoom buttons:
var items = ((ImageEditToEditModeBehavior)sender).EditMenuItems;
foreach (var item in items) {
if (item is ImageEditToolButtonInfo button
&& button.Command == ((ImageEditToEditModeBehavior)sender).ZoomCommand)
e.EditMenuItems.Remove(item);
}
// Add OK and Cancel buttons:
e.EditMenuItems.Add(new ImageEditToolSeparatorInfo());
e.EditMenuItems.Add(new ImageEditToolButtonInfo() {
Glyph = ImageEditToolButtonHelper.ImageIdToImageSource("ok"),
ToolTip = "OK",
Command = new DelegateCommand(Confirm)
});
e.EditMenuItems.Add(new ImageEditToolButtonInfo() {
Glyph = ImageEditToolButtonHelper.ImageIdToImageSource("cancel"),
ToolTip = "Cancel",
Command = new DelegateCommand(Close)
});
}
Private Sub editBehavior_CustomEditMenuItems(ByVal sender As Object, ByVal e As DevExpress.Xpf.Editors.CustomEditMenuItemsEventArgs)
' Remove Zoom buttons:
Dim items = (CType(sender, ImageEditToEditModeBehavior)).EditMenuItems
For Each item In items
If TypeOf item Is ImageEditToolButtonInfo AndAlso (CType(item, ImageEditToolButtonInfo)).Command = (CType(sender, ImageEditToEditModeBehavior)).ZoomCommand Then e.EditMenuItems.Remove(item)
Next
' Add OK and Cancel buttons:
e.EditMenuItems.Add(New ImageEditToolSeparatorInfo())
e.EditMenuItems.Add(New ImageEditToolButtonInfo() With {
.Glyph = ImageEditToolButtonHelper.ImageIdToImageSource("ok"),
.ToolTip = "OK",
.Command = New DelegateCommand(Confirm)
})
e.EditMenuItems.Add(New ImageEditToolButtonInfo() With {
.Glyph = ImageEditToolButtonHelper.ImageIdToImageSource("cancel"),
.ToolTip = "Cancel",
.Command = New DelegateCommand(Close)
})
End Sub
The CustomEditMenuItems event does not allow you to change items defined through the MenuTemplate property.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomEditMenuItems event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-imageedit-edit-images-in-separate-window/CS/ImageEditToEditModeBehavior/EditImageWindow.xaml#L83
<dxmvvm:Interaction.Behaviors>
<dxe:ImageEditToEditModeBehavior x:Name="editBehavior" CustomEditMenuItems="editBehavior_CustomEditMenuItems"/>
</dxmvvm:Interaction.Behaviors>
#line 83 "..\..\..\EditImageWindow.xaml"
this.editBehavior.CustomEditMenuItems += new System.EventHandler<DevExpress.Xpf.Editors.CustomEditMenuItemsEventArgs>(this.editBehavior_CustomEditMenuItems);
See Also
ImageEditToEditModeBehavior Class