ISupportIncrementalLoading内部的ScrollViewer不支持?不支持、ISupportIncrementalLoading、ScrollViewer

2023-09-03 06:06:28 作者:此账号已被永久冻结

我有一个的GridView 与 GridView.ItemsSource设定到实现 ISupportIncrementalLoading 。通过实施这一点,我的目标只有加载需要显示的项目,以提高加载时间和用户界面的响应。该框架处理这对我来说,它的伟大工程。

I have a GridView with GridView.ItemsSource set to a collection that implements ISupportIncrementalLoading. By implementing this, I am aiming to improve load time and UI responsiveness by only loading items that are needed for display. The framework handles this for me and it works great.

    <GridView ItemsSource="{Binding Items}">
        <GridView.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Text}"/>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>

然而,如果我包上面的XAML中的ScrollViewer像下面的项目的整个集合负荷作为虽然GridView控件无法说出它的边界

However, if I wrap the above XAML in a ScrollViewer like the following, the entire collection of Items loads as though the GridView is unable to tell where it's boundaries are.

<ScrollViewer>
    <GridView ItemsSource="{Binding Items}">
        <GridView.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Text}"/>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>
</ScrollViewer>

我知道ScollViewer将允许它的内容,它要填补尽可能多的空间,所以在这里的影响有一定道理;这只是一个意外烦恼。有没有人有一个解决方案,以获得解决这个问题?

I know that the ScollViewer will allow it's content to fill as much space as it wants, so the effect here does make sense; it is just an unforeseen annoyance. Does anyone have a solution to getting around this problem?

注:我已经简化了code这里有个例子缘故。如果它有助于知道我要完成的:我的目标是有一个HubSection内的增量加载的GridView在我中心页。我中心页面有2 HubSections,一个是在600px的宽度,另在GridView它没有定义的宽度。的

推荐答案

可以解决这个问题很容易手动设置 GridView控件的大小。根据你的情况,你可能会做一次或者手柄上的 SizeChanged将事件的ScrollViewer 并设置的大小的GridView 的基础上的视口大小的属性的的ScrollViewer

You can fix that easily by setting the size of the GridView manually. Depending on your scenario you might do it once or perhaps handle the SizeChanged event on the ScrollViewer and set the size of the GridView based on the viewport size properties of the ScrollViewer.