开发者

WPF TreeView virtualization breaks as soon as anything is added to the window

开发者 https://www.devze.com 2023-03-28 03:48 出处:网络
Virtualization works when the TreeView is the only thing in the Window. For example: <Grid> <vw:FontTreeViewx:Name=\"fontTreeViewControl\" VerticalAlignment=\"Stretch\" HorizontalAlignment=\

Virtualization works when the TreeView is the only thing in the Window. For example:

<Grid>
    <vw:FontTreeView  x:Name="fontTreeViewControl" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderThickness="0" />
</Grid>

But even simply adding row definitions breaks the virtualization entirely:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <vw:FontTreeView  x:Name="fontTreeViewControl" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderThickness="0" />

</Grid>

My TreeViewItem style has the following trigger:

<Style.Triggers>
    <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
           开发者_运维百科         <VirtualizingStackPanel/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Trigger>
</Style.Triggers>

And of course the TreeView has VirtualizingStackPanel.IsVirtualizing="True"

Q. How can I have other elements in my window without breaking the virtualization? Thank you help is much appreciated.


My problem was with setting the Height to Auto. It must either be fixed, or use a * instead. In my instance in RowDefinition.

0

精彩评论

暂无评论...
验证码 换一张
取 消