Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
821 views
in Technique[技术] by (71.8m points)

.net - ISupportIncrementalLoading inside ScrollViewer not supported?

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>

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>

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?

Note: I've simplified the code here for example sake. In case it helps to know what I'm trying to accomplish: my goal is to have an incrementally loaded GridView inside a HubSection on my Hub page. My hub page has 2 HubSections, one that is at 600px width and the other with the GridView in it with no width defined.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...