Example #1 (Works):
<ScrollView x:Name="svMain" Grid.Row="0">
<Grid Margin="20" x:Name="gridSV">
<VerticalStackLayout Grid.Row="2" x:Name="vslFooter" VerticalOptions="End">
<local:Paginator x:Name="localPaginator" Paginate="localPaginator_Paginate"></local:Paginator>
</VerticalStackLayout>
</Grid>
</ScrollView>
When the last page is tapped from the <local:Paginator />
, the data is pulled and the BindableProperty
is updated. Then (svMain as IView).InvalidateMeasure();
is triggered which properly updates the view based on the number of results, shortening the page length.
Code behind:
private async void localPaginator_Paginate(object sender, PaginateEventArgs e)
{
await svMain.ScrollToAsync(0, 0, false);
await LoadPosts(e.GoToPageNo);
(svMain as IView).InvalidateMeasure();
}
Example #2 (Not Working):
<RefreshView x:Name="rvMain" Grid.Row="0" IsRefreshing="{Binding IsRefreshing}" Command="{Binding RefreshCommand}" RefreshColor="{DynamicResource Primary}">
<ScrollView x:Name="svMain" Grid.Row="0">
<Grid Margin="20" x:Name="gridSV">...</Grid>
</ScrollView>
</RefreshView>
When the RefreshView
Command runs, it updates the data for the BindableProperty
. Here is the code behind for the RefreshView.Command
:
ICommand refreshCommand = new Command(async () =>
{
rvMain.IsRefreshing = true;
await LoadResults(PageNo);
rvMain.IsRefreshing = false;
(svMain as IView).InvalidateMeasure();
});
rvMain.Command = refreshCommand;
However, (svMain as IView).InvalidateMeasure();
does not reset the height of the ScrollView
. So there seems to be an issue with InvalidateMeasure()
on the ScrollView
when within a RefreshView
.
Am I maybe calling (svMain as IView).InvalidateMeasure();
too soon? I tried adding a delay and also a background task for InvalidateMeasure()
, but neither worked.