ShowNavigationItemController.CustomUpdateSelectedItem Event
Occurs when the ShowNavigationItemController.ShowNavigationItemAction‘s selected item is about to change, to reflect the change of the active View.
Namespace: DevExpress.ExpressApp.SystemModule
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Event Data
The CustomUpdateSelectedItem event's data class is DevExpress.ExpressApp.SystemModule.CustomUpdateSelectedItemEventArgs.
Remarks
This event is raised by the ShowNavigationItemController.UpdateSelectedItem method. Handle this event to perform specific actions when the ShowNavigationItemAction‘s selected item is about to change. You can perform the change of the selected item in a custom way. In this instance, set the event handler’s CustomUpdateSelectedItemEventArgs.Handled parameter to true.
The following example specifies the selected item:
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.SystemModule;
namespace MainDemo.Module {
public class SelectedNavigationItemController : WindowController {
public SelectedNavigationItemController() {
TargetWindowType = WindowType.Main;
}
protected override void OnActivated() {
base.OnActivated();
Frame.GetController<ShowNavigationItemController>().CustomUpdateSelectedItem += SelectedNavigationItemController_CustomUpdateSelectedItem;
Application.ViewShowing += Application_ViewShowing;
}
bool cancelSelectedNavigationItemChange;
private void Application_ViewShowing(object sender, ViewShowingEventArgs e) {
if (e.View.Id == "Employee_DetailView" && e.SourceFrame?.View?.Id == "Person_ListView") {
cancelSelectedNavigationItemChange = true;
}
}
private void SelectedNavigationItemController_CustomUpdateSelectedItem(object sender, CustomUpdateSelectedItemEventArgs e) {
if (cancelSelectedNavigationItemChange) {
cancelSelectedNavigationItemChange = false;
e.Handled = true;
e.ProposedSelectedItem = ((ShowNavigationItemController)sender).ShowNavigationItemAction.SelectedItem;
}
}
protected override void OnDeactivated() {
base.OnDeactivated();
Frame.GetController<ShowNavigationItemController>().CustomUpdateSelectedItem -= SelectedNavigationItemController_CustomUpdateSelectedItem;
Application.ViewShowing -= Application_ViewShowing;
}
}
}