Good day. Found a lot of information on the problem of interest, but not a single example could be applied to your project. The hitch is that different types of data are nested in the TreeView and I cannot understand how to select them. Here is a Model
public class Algorithms { public AlgorithmsType TypeName { get; set; } public List<Algorithm> Algorithm { get; set; } } public class Algorithm { public string Name { get; set; } public string Text { get; set; } } Next ViewModel
public class AlgorithmsViewModel : ViewModelBase { private Algorithm _selectedAlgorithm; public Algorithm SelectedAlgorithm { get { return _selectedAlgorithm; } set { _selectedAlgorithm = value; RaisePropertyChanged(); } } public List<Algorithms> AlgorithmList { get; set; } public AlgorithmsViewModel() { } } } And View
<Window.Background> <RadialGradientBrush> <GradientStop Color="#FF7831AA" Offset="1"/> <GradientStop Color="#FFDDB7F7" Offset="0.009"/> </RadialGradientBrush> </Window.Background> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="106*"/> <ColumnDefinition Width="181*"/> </Grid.ColumnDefinitions> <StackPanel CanVerticallyScroll="True" Grid.Column="1" Margin="0,0,0,10"> <Border BorderThickness="5" BorderBrush="#FFF9F8F7" Margin="10,10,10,10" Height="242"> <TextBox Text="{Binding SelectedAlgorithms}" IsReadOnly="True" TextWrapping="Wrap" Margin="5"/> </Border> </StackPanel> <Button x:Name="btnGo" Content="ΠΠ΅ΡΠ΅ΠΉΡΠΈ" HorizontalAlignment="Left" Margin="274,257,0,0" VerticalAlignment="Top" Width="75" Grid.Column="1" Height="22"/> <TreeView x:Name="tvAlgorithms" ItemsSource="{Binding AlgorithmList}" Grid.Column="0" HorizontalAlignment="Left" Height="269" VerticalAlignment="Top" Width="198" Margin="10,10,0,0"> <TreeView.Resources> <HierarchicalDataTemplate ItemsSource="{Binding Algorithm}" DataType="{x:Type models:Algorithms}"> <Label> <Label.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding TypeName}" Value="Symmetrical"> <Setter Property="Label.Content" Value="Π‘ΠΈΠΌΠ΅ΡΡΠΈΡΠ΅ΡΠΊΠΈΠ΅"/> </DataTrigger> <DataTrigger Binding="{Binding TypeName}" Value="Asymmetric"> <Setter Property="Label.Content" Value="ΠΡΠΈΠΌΠ΅ΡΡΠΈΡΠ΅ΡΠΊΠΈΠ΅"/> </DataTrigger> </Style.Triggers> </Style> </Label.Style> </Label> </HierarchicalDataTemplate> <DataTemplate DataType="{x:Type models:Algorithm}"> <Label Content="{Binding Name}"/> </DataTemplate> </TreeView.Resources> </TreeView> </Grid> So, how can I get the coveted object Algorithm, to continue to work with him?