Description
I created a tree view similar to your "Pictures and Music Library tree view" example except I replaced the text block in the data template with a grid view with two text blocks. This caused two problems with nested nodes: (1) when a node is expanded the first column of grid view items in the child nodes aren't rendered until you mouse over them, and (2) the child nodes are rendered out of order after expanding a second time (i.e., expanding a parent node, collapsing it and expanding it again). Internally the child nodes are still in the correct order because if you change to a simple text block data template while debugging the child nodes will be rendered instantly in the correct order.
Here is my data template using a grid view in which child nodes are rendered out of order on expanding the parent node a second time:
<DataTemplate x:Key="TreeViewItemDataTemplate1">
<GridView>
<TextBlock Text="{Binding Content.Column1Item}"/>
<TextBlock Text="{Binding Content.Column2Item}"/>
</GridView>
</DataTemplate>
This doesn't happen when using this simple data template (Content displays the ToString of the class):
<DataTemplate x:Key="TreeViewItemDataTemplate">
<Grid>
<TextBlock Text="{Binding Content}"/>
</Grid>
</DataTemplate>
If fact switching the data template live in xaml during a debug session will switch the order of the child nodes to the correct order.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: d5ba995b-8bf3-407c-7b87-015d22d813f1
- Version Independent ID: 52c553b6-e94d-2810-4123-8ee215b002bf
- Content: Tree view - UWP app developer
- Content Source: windows-apps-src/design/controls-and-patterns/tree-view.md
- GitHub Login: @jwmsft
- Microsoft Alias: jimwalk