Home > Enterprise >  ScrollView doesn't work in RefreshView .net Maui
ScrollView doesn't work in RefreshView .net Maui

Time:12-20

I have a ScrollView in my .net Maui application. It contains a RefreshView with a CollectionView. It worked fine but yesterday it doesn't scroll anymore.

Here a video of the issue: https://de.files.fm/u/3rhsdu786

I tested the ScrollView with some Frames and it worked, so there must be a problem with the RefreshView or with the combination. I also tried to create a new page and inserted the old code but it also didn't work. Here is my xaml code:

<ScrollView>
        <StackLayout>
            <!--Der Frame ist Visible, wenn für den Tag eine für den Schüler betreffende Nachricht existiert ansonsten bleibt diese Nachricht unsichtbar-->
            <Button Text="Neue Nachrichten unter Aktuelles!" Command="{Binding OnMessage}" IsVisible="{Binding IsVisibleInfo}" CornerRadius="30" Margin="0,15,0,0" HorizontalOptions="Center"/>

            <Frame IsVisible="{Binding IsVisibleNoAlert}" HorizontalOptions="Center" BackgroundColor="Transparent">
                <StackLayout VerticalOptions="Start" HorizontalOptions="Center">
                    <Label Text="Keine Vertretung!" FontSize="Title" HorizontalTextAlignment="Center" VerticalOptions="Start" Margin="10"/>
                    <Label Text="Heute hast du keine Vertretung. Dein Tag findet ganz normal statt." HorizontalTextAlignment="Center"/>
                    <Label Text="{Binding Status}" HorizontalOptions="Center" Margin="20" TextColor="Gray" VerticalOptions="StartAndExpand" IsVisible="{Binding IsVisibleNoAlert}"/>
                </StackLayout>
            </Frame>

            <RefreshView x:DataType="vm:TodayViewModel" Command="{Binding LoadStandInsCommand}" IsRefreshing="{Binding IsBusy, Mode=TwoWay}" IsEnabled="{Binding RefreshIsEnabled}" Margin="30,10,30,30">
                <StackLayout Orientation="Vertical">
                    <Label Text="{Binding Status}" HorizontalOptions="Center" TextColor="Gray" VerticalOptions="StartAndExpand" IsVisible="{Binding IsVisibleView}"/>
                    <CollectionView ItemsSource="{Binding StandIns}" SelectionMode="None" IsVisible="{Binding IsVisibleView}">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <StackLayout x:DataType="model:StandIn" Margin="0,10,0,10">
                                    <Frame HeightRequest="110" BackgroundColor="{AppThemeBinding Light={StaticResource WhiteMode2nd}, Dark={StaticResource DarkMode2nd}}" BorderColor="{Binding Color}" CornerRadius="10">
                                        <StackLayout Margin="-20" Orientation="Horizontal">
                                            <Line BackgroundColor="{Binding Color}" HeightRequest="170" WidthRequest="5" HorizontalOptions="Start"/>
                                            <Grid HorizontalOptions="FillAndExpand" Margin="10,5,10,5">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="*"/>
                                                    <RowDefinition Height="*"/>
                                                    <RowDefinition Height="0.75*"/>
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="0.7*"/>
                                                    <ColumnDefinition Width="0.3*"/>
                                                </Grid.ColumnDefinitions>
                                                <Label Text="{Binding Stunde}" Style="{StaticResource LableStyleStandIn}"  Margin="5,0,0,0"/>
                                                <Label Text="{Binding Fach}" Style="{StaticResource LableStyleStandIn}" Grid.Row="1"/>
                                                <Label Text="{Binding Art}" FontSize="17" Style="{StaticResource LableStyleStandIn}" Grid.Row="2"/>
                                                <Label Text="{Binding Raum}" Style="{StaticResource LableStyleStandIn}" Grid.Column="1" Grid.Row="1"/>
                                                <Label Text="{Binding Lehrer}" FontSize="17" Style="{StaticResource LableStyleStandIn}" Grid.Column="1" Grid.Row="2"/>
                                            </Grid>
                                        </StackLayout>
                                    </Frame>
                                </StackLayout>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </StackLayout>
            </RefreshView>
        </StackLayout>
    </ScrollView>

    <!--Der Button um in die Refreshview entweder die Vertretung für heute oder morgen zu laden-->
    <Frame Style="{StaticResource ButtonStyleSwitchDay}" >
        <Grid Margin="-15">
            <Button Command="{Binding ChangeSide}" Background="Transparent" BorderColor="Transparent"/>
            <Image Source="{Binding ButtonImageDay}"/>
        </Grid>
    </Frame>
</Grid>

The ViewModel workes fine, so there is no problem with it.

Thanks for helping me.

CodePudding user response:

Credits: ewerspej

RefreshView must be on the outside and ScrollView on the inside like below:

<RefreshView >
    <ScrollView>
     
        ````
    </ScrollView>
</RefreshView>

Ref: https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/refreshview?view=net-maui-7.0

  • Related