using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using MaterialDesignColors.WpfExample.Domain; namespace MaterialDesignColors.WpfExample { /// /// Interaction logic for Trees.xaml /// public partial class Trees : UserControl { public Trees() { InitializeComponent(); } public TreesViewModel ViewModel => DataContext as TreesViewModel; /// /// TreesView's SelectedItem is read-only. Hence we can't bind it. There is a way to obtain a selected item. /// /// /// private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) { if (ViewModel == null) return; ViewModel.SelectedItem = e.NewValue; } } }