Selected Item in WPF Tree Navigator (SfTreeNavigator)

The SelectedItem property of SfTreeNavigator can be used to get or set the SelectedItem in SfTreeNavigator.

Please find the code example for the same from below:

<!--Binding the selecteditem for TreeNavigator-->
<navigation:SfTreeNavigator Header="MailBox" x:Name="TreeNavigator" Width="500" Height="300" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<navigation:SfTreeNavigatorItem Header="Mail"/>
<navigation:SfTreeNavigatorItem Header="Favorite Folders"/>
<navigation:SfTreeNavigatorItem  Header="Contacts">
<navigation:SfTreeNavigatorItem  Header="Task"/>
<navigation:SfTreeNavigatorItem  Header="Notes"/>
public partial class MainWindow : ChromelessWindow
    public MainWindow()
        this.DataContext = new ViewModel();
//Set the selecteditem
        (this.DataContext as ViewModel).SelectedItem = TreeNavigator.Items[1];
//Initiate the viewmodel class
    public class ViewModel
        private object selecteditem;
        public object SelectedItem
// Get the selecteditem
                return selecteditem;
//Set the selecteditem
                selecteditem = value;
'Initiate the viewmodel class
Partial Public Class MainWindow
Inherits ChromelessWindow
Public Sub New()
Me.DataContext = New ViewModel()
(TryCast(Me.DataContext, ViewModel)).SelectedItem = TreeNavigator.Items(1)
End Sub
Public Class ViewModel
Private selecteditem As Object

'Get the selecteditem
Public Property SelectedItem As Object
Return SelectedItem
End Get

'Set the selecteditem
Set(ByVal value As Object)
selecteditem = value
End Set
End Property
End Class


Fig i: Shows the Item has been selected in SfTreeNavigator