Skip to main content

SvgImageBox.SelectionChanging Event

Fires when the item selection is about to be changed. Allows you to cancel the current operation.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.Utils.v23.2.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

public event SvgImageSelectionChangingEventHandler SelectionChanging

Event Data

The SelectionChanging event's data class is SvgImageSelectionChangingEventArgs. The following properties provide information specific to this event:

Property Description
Action Gets or sets how the selected item collection has been changed.
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
Item Gets or sets the currently processed item.

Remarks

The event’s Item parameter specifies the item whose selected state is about to be changed. Use the Action parameter to identify the item’s new state.

If all items are deselected at once (the SvgImageBox.Selection collection is cleared), the Item parameter returns null and the Action parameter returns Clear.

To prevent an item’s selected state from being changed, set the event’s Cancel parameter to true.

Example

This example shows how to handle the SelectionChanging event to prevent the current selection from being changed.

private void svgImageBox1_SelectionChanging(object sender, DevExpress.XtraEditors.SvgImageSelectionChangingEventArgs e) {
    //Prevent item selection from being cleared when a user clicks on the empty space
    if (e.Action == DevExpress.XtraEditors.SvgImageSelectionChangeAction.Clear) {
        e.Cancel = true;
        return;
    }

    //Prevent an item from being selected/deselected.
    if (e.Item == svgImageBox1.HoveredItem) {
        e.Cancel = true;
        return;
    }
}
See Also