XAML ScrollView不工作在RefreshView .net毛伊岛

4dbbbstv  于 2022-12-20  发布在  .NET
关注(0)|答案(1)|浏览(99)

我在我的.net Maui应用程序中有一个ScrollView。它包含了一个带有CollectionView的RefreshView。它工作正常,但是昨天它不再滚动了。
下面是这个问题的视频:https://de.files.fm/u/3rhsdu786
我用一些框架测试了ScrollView,它工作正常,所以一定是RefreshView或两者的组合有问题。我也试着创建一个新页面并插入旧代码,但也不起作用。下面是我的xaml代码:

<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>

ViewModel工作正常,因此没有问题。
谢谢你帮我。

6yjfywim

6yjfywim1#

作者:ewerspej
RefreshView必须位于外侧,ScrollView必须位于内侧,如下所示:

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

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

相关问题