vendredi 11 septembre 2020

Build a TreeViev based on the object obtained by reflection

It is necessary to display the element, presented in the form as in the picture, in the form of a tree. The object itself is created at compile time. Object to viewing. An attempt to make in this form

    <TreeView
            Grid.Row="1"
            Grid.Column="0"
            ItemsSource="{Binding LanguageInformation.Items}">
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                </Style>
            </TreeView.ItemContainerStyle>
            <TreeView.Resources>
                <HierarchicalDataTemplate DataType="{x:Type local:LocalizationBrowserViewModel}" ItemsSource="{Binding LanguageInformation.Items}">
                    <TextBlock Text="{Binding}"/>
                </HierarchicalDataTemplate>
            </TreeView.Resources>
        </TreeView>

Class for presentation

public class Element
{
    public string Name { get; set; }
    public ObservableCollection<object> Items { get; set; }
    public Element()
    {
        this.Items = new ObservableCollection<object>();

    }
}




Aucun commentaire:

Enregistrer un commentaire