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

.NET MAUI:FlyoutItem仅显示单个ShellContent标签页配置求助

.NET MAUI Shell 单个ShellContent在FlyoutItem中不显示的解决方法

问题原因

.NET MAUI Shell 默认会对仅包含单个 ShellContent 的 FlyoutItem 做"扁平化"处理:直接将该页面作为导航根,不在侧边栏(Flyout)中显示对应的标签项。当添加第二个 ShellContent 时,Shell 会保留 FlyoutItem 的层级结构,因此标签项能正常显示。

解决方法

给 FlyoutItem 添加 FlyoutDisplayOptions="AsMultipleItems" 属性,强制 Shell 即使在单个 ShellContent 的情况下也显示侧边栏标签项:

<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
    <ShellContent
        Title="Preferences"
        ContentTemplate="{DataTemplate views:PreferencesViewPage}"
        IsVisible="{Binding IsPreferencesIconFocused}"
        Route="Preferences" />
</FlyoutItem>

额外检查点

  • 确认绑定的 IsPreferencesIconFocused 属性初始值为 true,如果初始为 false,即使配置正确也不会显示标签项
  • 确保 PreferencesViewPage 已在项目中正确定义,且命名空间 views 已在XAML头部声明

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 19:54:58