1

有没有简单的方法来装饰VirtualizingStackPanel?如果我VirtualizingStackPanel直接输入ScrollViewer,虚拟化就可以了。我的目标是覆盖该Decorator.OnRender()方法并在Panel.

<Window.Resources>
    <ControlTemplate x:Key="MyControlTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <ScrollViewer CanContentScroll="True">
                <Border> <!--Decorator breaks virtualization-->
                    <VirtualizingStackPanel IsItemsHost="True"/>
                </Border>
            </ScrollViewer>
        </Grid>
    </ControlTemplate>
</Window.Resources>

<ItemsControl x:Name="MyControl" Template="{StaticResource MyControlTemplate}"/>
4

0 回答 0