Note that there are some explanatory texts on larger screens.

plurals
  1. POStyle TreeView but keep it Virtualized
    primarykey
    data
    text
    <p>The <strong>Virtualization</strong> on my <strong>TreeView</strong> works when I have only styled the <strong>TreeViewItem</strong> with this bit of xaml in the style:</p> <pre><code>&lt;Style.Triggers&gt; &lt;Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true"&gt; &lt;Setter Property="ItemsPanel"&gt; &lt;Setter.Value&gt; &lt;ItemsPanelTemplate&gt; &lt;VirtualizingStackPanel/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; </code></pre> <p>But then if I try and give the <strong>TreeView</strong> itself a style with <strong>Style={Resource}</strong> the virtualization breaks, i.e:</p> <pre><code>&lt;Style x:Key="FontTreeViewStyle" TargetType="{x:Type TreeView}"&gt; &lt;Setter Property="OverridesDefaultStyle" Value="True" /&gt; &lt;Setter Property="SnapsToDevicePixels" Value="True" /&gt; &lt;Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /&gt; &lt;Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="TreeView"&gt; &lt;Border Name="Border" CornerRadius="1" BorderThickness="1" BorderBrush="{DynamicResource BorderMediumColor}" Background="{DynamicResource ControlLightColor}"&gt; &lt;ScrollViewer Focusable="False" CanContentScroll="False" Padding="4"&gt;&lt;!-- Style="{StaticResource MyScrollViewer}"--&gt; &lt;ItemsPresenter /&gt; &lt;/ScrollViewer&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload