C#C
C#3y ago
1 reply
Will Pittenger

✅ WPF TreeView only shows icon and only for the root item

have a tree declared with the following XAML and added from code behind a single item for the root. The root item does have children and a name for each item. But nothing appears beyond a single icon. XAML is reporting no binding failures. I've put breakpoints in for the Children, LocalizedName, and LocalizedLongDesc properties, but of those, only Children is called. What's going on?
<TreeView
    x:Name="treeLogicalSelector">
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate
            DataType="TreeData:VisualTreeData"
            ItemsSource="{Binding Children}">
            <StackPanel
                Orientation="Horizontal"
                ToolTip="{Binding LocalizedLongDesc}">
                <Emoji:TextBlock
                    Text="{Binding Icon}"
                    VerticalAlignment="Center" />
                <Label
                    Content="{Binding LocalizedName}"
                    VerticalAlignment="Center" />
            </StackPanel>
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
</TreeView>
Was this page helpful?