Skip to main content
A newer version of this page is available. .

NavBarItemSelectingEventArgs.Cancel Property

Gets or sets a value indicating whether the operation which raised an event should be canceled.

Namespace: DevExpress.Xpf.NavBar

Assembly: DevExpress.Xpf.NavBar.v20.2.dll

NuGet Packages: DevExpress.WindowsDesktop.Wpf.NavBar, DevExpress.Wpf.Navigation

Declaration

public bool Cancel { get; set; }

Property Value

Type Description
Boolean

true if the operation raising the event should be canceled; otherwise, false.

Remarks

The NavBarItemSelectingEventArgs object is passed to events that fire before specific initiated actions are completed. The Cancel property of this object enables you to cancel the action which is about to be performed.

For example, this property is useful when you handle the NavBarViewBase.ItemSelecting event. Set this property to true to cancel selection of the processed item. This can be used if you want to prohibit item selection with respect to specific conditions.

Example

In this example, the NavBarViewBase.ItemSelecting event is handled, to invoke a confirmation dialog allowing the selection of a specific item (‘Private’) to be canceled.

View Example

private void navBar_ItemSelecting(object sender, NavBarItemSelectingEventArgs e){
    if (e.NewItem.Content.ToString() == "Private"){
        MessageBoxResult result = MessageBox.Show("Are you sure to select the 'Private' item?", "Confirm Dialog", MessageBoxButton.YesNo);
        e.Cancel = (result == MessageBoxResult.No);
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Cancel property.

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.

See Also