Handling Selection in WPF Navigation Drawer (SfNavigationDrawer)

6 Feb 20251 minute to read

This section explains the handling of selection in SfNavigationDrawer.

The SelectedItem property is used for getting or setting the currently selected item of the Navigation Drawer. There are two cases in accessing the SelectedItem property.

The first is when the Navigation Drawer is populated with NavigationItems, then the SelectedItem property is of type NavigationItem.

var selectedItem = this.navigationDrawer.SelectedItem as NavigationItem;

The other one is when the Navigation Drawer is bound to a collection of custom objects, the SelectedItem is of the type of the custom object.

var selectedItem = this.navigationDrawer.SelectedItem as NavigationModel;

NOTE

View sample in GitHub