You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MAUI中Flyout详情在Android不加载,Windows正常问题求助

MAUI Flyout菜单Android端点击无显示问题(Windows端正常)

我开发了一款面向平板和桌面的MAUI应用,由Xamarin迁移而来,迁移过程十分艰难。原Xamarin项目使用MasterDetailPage技术,当前MAUI实现采用了不同的技术方案。

目前遇到的问题:Windows系统中,点击Flyout菜单选项后详情内容可正常加载;但在Android系统中,点击后无任何显示,虽然调试时能确认代码已经执行。查阅相关文档后未找到该行为的原因,恳请帮助。

问题演示:Android端点击菜单选项后无内容显示,Windows端点击后正常加载详情页。

主页面XAML代码

<ScrollView>
    <CollectionView x:Name="collectionView"
                    x:FieldModifier="public"
                    SelectionMode="Single"
                    SelectionChanged="collectionView_SelectionChanged"
                    Background="White">

        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Grid Padding="5,10">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30"/>
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Image Grid.Column="0" Source="{Binding IconSource}" BackgroundColor="Transparent" />
                    <StackLayout Orientation="Horizontal" Grid.Column="1" BackgroundColor="Transparent">
                        <Label Grid.Column="0" Grid.Row="0"
                               Margin="10,0"
                               Text="{Binding Title}"
                               FontSize="20"
                               FontAttributes="Bold"
                               VerticalOptions="Center"/>
                        <Image Grid.Column="0" Grid.Row="0" Source="checkw.png" HorizontalOptions="End" VerticalOptions="Start" HeightRequest="16"></Image>
                    </StackLayout>
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
    
</ScrollView>

后台C#代码

private void collectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    var item = e.CurrentSelection.FirstOrDefault() as FlyoutPageItem;
    if (item != null)
    {
        FlyoutPage page = (FlyoutPage)this.Parent;

        page.Detail = new NavigationPage(new Pages.Claim.Actions());// new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
        page.Title = item.Title;
        //page.IsPresented = false;
    }
}

protected override void OnNavigatedTo(NavigatedToEventArgs args)
{
    base.OnNavigatedTo(args);

    List<FlyoutPageItem> pages = new()
    {
        new FlyoutPageItem {Title = "Actions", TargetType = typeof(Pages.Claim.Actions), IconSource = "actionact.png" },
        new FlyoutPageItem {Title = "Agreement", TargetType = typeof(Pages.Claim.Agreement), IconSource = "actionagr.png" },
        new FlyoutPageItem {Title = "Asbestos", TargetType = typeof(Pages.Claim.Asbestos), IconSource = "actionasb.png" },
        new FlyoutPageItem {Title = "Buildings", TargetType = typeof(Pages.Claim.Buildings), IconSource = "actionbld.png" },


    };

    collectionView.ItemsSource = pages;
}

内容的提问来源于stack exchange,提问作者djack109

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 11:15:43