简体   繁体   English

3 个点表示 .net Maui 应用程序中内容页面中的 ToolbarItems 仅在设备处于暗模式时显示

[英]3 dots representing ToolbarItems from a Content Page in a .net Maui app only showing when the device is in dark mode

此图像来自设备处于暗模式时的图像

此图像是设备处于灯光模式时的样子

image 1 is when the device is on dark mode.图 1 是设备处于暗模式时的情况。

image 2 is when the device is on light mode.图 2 是设备处于灯光模式时的情况。

I can still click it and access the toolbarItems that I have defined but the icon is not visible.我仍然可以单击它并访问我定义的 toolbarItems 但图标不可见。

Any idea on why this is happening?知道为什么会这样吗?

is it a style problem?是风格问题吗? Here is the styles i got, I am using shells这是我得到的 styles,我正在使用 shell

    <Style TargetType="Shell" ApplyToDerivedTypes="True">
    <Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
    <Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default={StaticResource White}}" />
    <Setter Property="Shell.TitleColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource White}}" />
    <Setter Property="Shell.DisabledColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
    <Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray200}}" />
    <Setter Property="Shell.NavBarHasShadow" Value="False" />
    <Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
    <Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
    <Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
    <Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
</Style>

<Style TargetType="NavigationPage">
    <Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
    <Setter Property="BarTextColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource White}}" />
    <Setter Property="IconColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource White}}" />
</Style>

<Style TargetType="TabbedPage">
    <Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray950}}" />
    <Setter Property="BarTextColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
    <Setter Property="UnselectedTabColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
    <Setter Property="SelectedTabColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray200}}" />
</Style>

In your.xaml(take MainPage.xaml as an example), add this:在your.xaml(以MainPage.xaml为例)中添加:

...
<ContentPage.ToolbarItems>        
      <ToolbarItem Text="Example Item"                 
                   Order="Secondary"                 
                   Priority="0" />    
</ContentPage.ToolbarItems>
...

For more information, you can refer to Xamarin.Forms ToolbarItem .更多信息可以参考Xamarin.Forms ToolbarItem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM