I want the default value of VirtualizingPanel.VirtualizationMode
to Recycling
, mainly on TreeViewItems
. It may be something simple I'm missing but I've tried all these:
<TreeView VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.CacheLengthUnit="Pixel"
VirtualizingPanel.VirtualizationMode="Recycling"/>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}">
<Setter Property="VirtualizingPanel.VirtualizationMode" Value="Recycling" />
</Style>
static MainWindow()
{
VirtualizingPanel.VirtualizationModeProperty.OverrideMetadata(
typeof(VirtualizingPanel), new FrameworkPropertyMetadata(VirtualizationMode.Recycling));
VirtualizingPanel.VirtualizationModeProperty.OverrideMetadata(
typeof(MainWindow), new FrameworkPropertyMetadata(VirtualizationMode.Recycling));
VirtualizingPanel.VirtualizationModeProperty.OverrideMetadata(
typeof(TreeViewItem), new FrameworkPropertyMetadata(VirtualizationMode.Recycling));
VirtualizingPanel.VirtualizationModeProperty.OverrideMetadata(
typeof(VirtualizingStackPanel), new FrameworkPropertyMetadata(VirtualizationMode.Recycling));
}
But it all seems to do nothing. According to the Xaml live property explorer.
How to reproduce:
- Download and run the source code from github in Visual Studio in debug mode.
- Open the "Live Visual Tree" window in Visual Studio and find a
VirtualizingStackPanel
under someTreeViewItem
. - Right-click, select properties, and find the
VirualizationMode
property.