windows 如何使视图单元中的menuitems.contextactions显示在MAUI中的正确页面上?

xkftehaa  于 2023-06-24  发布在  Windows
关注(0)|答案(1)|浏览(72)

下面的代码运行得非常好,除了<ViewCell.ContextActions>在运行程序时在前一页中显示了toolbaritem(沿着中的所有内容)。我试过用菜单项来代替,但它们似乎也会显示在另一个页面上。

<ContentPage.Resources>
    <ResourceDictionary>
        <toolkit:SelectedItemEventArgsConverter x:Key="SelectedItemEventArgsConverter"/>
    </ResourceDictionary>
</ContentPage.Resources>

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Add" Command="{Binding AddCommand}"/>
    <ToolbarItem Text="Back" x:Name="ReturnToHomePageButton" Clicked="ReturnToHomePageButton_Clicked"/>
</ContentPage.ToolbarItems>

<VerticalStackLayout>
    <ListView
    BackgroundColor="Transparent"
    CachingStrategy="RecycleElement"
    HasUnevenRows="True"
    IsPullToRefreshEnabled="True"
    IsRefreshing="{Binding IsBusy, Mode=OneWay}"
    ItemsSource="{Binding Review}"
    RefreshCommand="{Binding RefreshCommand}"
    RefreshControlColor="Red"
    SelectionMode="None"
    SeparatorVisibility="None">
        <ListView.ItemTemplate>
            <DataTemplate x:DataType="model:Review">
                <ViewCell>
                    <ViewCell.ContextActions>
                        <ToolbarItem
                            Command="{Binding Source={x:Reference ReviewPage}, Path=BindingContext.RemoveCommand}"
                            CommandParameter="{Binding .}"
                            IsDestructive="True"
                            Text="Delete" />
                    </ViewCell.ContextActions>
                    <Grid Padding="10">
                        <Frame CornerRadius="20" HasShadow="True">
                            <StackLayout Orientation="Horizontal">
                                <StackLayout VerticalOptions="Center">
                                    <Label
                                        FontSize="Large"
                                        Text="{Binding Username}"
                                        VerticalOptions="Center"/>
                                    <controls:SimpleRatingControl 
                                        Amount="5"
                                        CurrentValue="{Binding Stars}"
                                        AccentColor="Yellow"
                                        StarSize="36" 
                                        VerticalOptions="End" />
                                    <Label
                                        FontSize="Small"
                                        Text="{Binding Text}"
                                        VerticalOptions="Center"/>
                                </StackLayout>
                            </StackLayout>
                        </Frame>
                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</VerticalStackLayout>


该项目有两个视图/页面,主页面和信息页面。infopage在listview中显示了几个评论(如上面的代码所示),但是当长时间单击这些评论以显示contextactions下的toolbaritem时,toolbaritem显示在主页中而不是infopage中。
信息页与示例审查x1c 0d1x
长时间点击评论后的主页

长时间点击评论后的信息页(没有任何变化)

相关问题