FlyoutPage的解决方案
的飞出FlyoutPage
属于类型ContentPage
因此图标应该设置在那里:
<ContentPage
IconImageSource="custom_menu_icon.png" />
</ContentPage>
您也可以在中定义它Styles.xaml
并将样式分配给页面:
<Style TargetType="ContentPage" x:Key="FlyoutStyle">
<Setter Property="IconImageSource" Value="custom_menu_icon.png" />
</Style>
<ContentPage
Style="{StaticResource FlyoutStyle}" />
</ContentPage>
也可以看看:https://learn.microsoft.com/dotnet/maui/user-interface/pages/flyoutpage?view=net-maui-7.0#create-a-flyoutpage
这假设您正在使用FlyoutPage
并不是Shell
.
壳牌解决方案
如果您使用 Shell,您可以按如下方式定义样式:
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<!-- skipping existing setters here -->
<Setter Property="Shell.FlyoutIcon" Value="custom_menu_icon.png" />
</Style>
查看更多:https://learn.microsoft.com/dotnet/maui/fundamentals/shell/flyout?view=net-maui-7.0#flyout-icon