Hi, @Bernard Lessard. Welcome to Microsoft Q&A.
You could get the SelectedItem of TreeView in code, refer to the following method:
MainWindow.xaml
<Grid>
<TreeView x:Name="MyTreeView" SelectedItemChanged="TreeView_SelectedItemChanged"></TreeView>
</Grid>
MainWindow.xaml.cs
private void TreeView_SelectedItemChanged(object sender,RoutedPropertyChangedEventArgs<object> e)
{
var item = MyTreeView.SelectedItem;
}
Also note that the SelectedItem of TreeView is a Get property, which could only be obtained but not set. It cannot be set, so SelectedItem doesn't make much sense in XAML, and as you could see, SelectedItem is not in XAML.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.