dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22k stars 1.72k forks source link

Toolbar Icons missing on Windows #5452

Closed david-maw closed 2 years ago

david-maw commented 2 years ago

Description

Opening up a NavigationPage with a child having ToolBarItems specified only shows icons if they are used elsewhere on the page (for example in an IconButton). For example if you use the XAML below on Windows the X and Z icons show up, but Y does not (all 3 show up on Android).

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Letter X" IconImageSource="{StaticResource GlyphX}"/>
        <ToolbarItem Text="Letter Y" IconImageSource="{StaticResource GlyphY}"/>
        <ToolbarItem Text="Letter Z" IconImageSource="{StaticResource GlyphZ}"/>
    </ContentPage.ToolbarItems>

    <VerticalStackLayout>
        <ImageButton Source="{StaticResource GlyphX}" HorizontalOptions="Center"/>
        <!--<ImageButton Source="{StaticResource GlyphY}" HorizontalOptions="Center"/>-->
        <ImageButton Source="{StaticResource GlyphZ}" HorizontalOptions="Center"/>
    </VerticalStackLayout>

If you uncomment the 'Y' Imagebutton, the 'Y' icon will show up in the toolbar.

Steps to Reproduce

  1. Unzip the project from MAUIToolBar.zip
  2. Compile and run it on Android and Windows, you should get the result illustrated below.
  3. Note the missing 'Y' icon in the tool bar on the Windows version.

MAUIToolBar

Version with bug

Preview 14 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 10

Did you find any workaround?

Yes, it turns out the icon shows up if it is declared on the page - it does not need to actually be shown, so you can set IsVisible false on the item that uses the Icon on the page and the icon will still show in the tool bar.

Relevant log output

No response

v-longmin commented 2 years ago

Verified the issue on Windows and Android, it's repro on windows Main 17.2.0 preview 2.0 32222.408.main, not repro on android 12 - API31. Repro Project: MAUIToolBar.zip

david-maw commented 2 years ago

Looks like it is fixed on RC1.