I have a TreeView
in XAML with multiple layers. Using this solution I can get a XAML-configured look for each of the different layers, and confirmed that it is UI virtualizing.
However, when I switch a particular layer's VirtualizingStackPanel
to have a different Orientation
(it doesn't matter whether through code like this solution, or with Snoop) than its parent, then UI virtualization switches off and the TreeView
realizes all the TreeViewItem
s as soon as I expand that layer.
While researching this behavior I noticed that within the reference source for VirtualizingStackPanel
as you drill into its MeasureOverride
function, you find this comment on line 2116:
Compute if this panel is different in orientation that (sic) either its parent or descendents
It appears that Microsoft has intentionally disabled UI virtualization for this case. So I have two questions:
- Why does it matter to have orientation consistency between layers?
- How can I get UI virtualization to work with a
TreeView
having different orientations within it?