unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.88k stars 720 forks source link

[Android/iOS] InvalidOperationException when using AppBarButton.Icon in NavigationBar in Debug Output #18545

Open agneszitte opened 2 hours ago

agneszitte commented 2 hours ago

Current behavior

When using AppBarButton.Icon in a NavigationBar, an exception is thrown in the Visual Studio debug output. These exceptions occur only when the AppBarButton is used within the NavigationBar. No exception is seen if the AppBarButton is used without the NavigationBar.

Expected behavior

No exceptions should occur in the Visual Studio debug output like for the other platforms.

How to reproduce it (as minimally and precisely as possible)

Sample app to repro: NavigationBarSampleApp.zip

With:

      <utu:NavigationBar Background="Orange"
                         Content="TEST">
        <utu:NavigationBar.PrimaryCommands>
          <AppBarButton Click="AppBarButton_Click">
            <AppBarButton.Icon>
              <FontIcon Glyph="&#xE109;" />
            </AppBarButton.Icon>
            <ToolTipService.ToolTip>
              <ToolTip Content="Add new row" />
            </ToolTipService.ToolTip>
          </AppBarButton>
        </utu:NavigationBar.PrimaryCommands>
      </utu:NavigationBar>

In VS Debug Ouput:


With:

      <utu:NavigationBar Background="DeepPink"
                         Content="TEST">
        <utu:NavigationBar.PrimaryCommands>
          <AppBarButton Icon="Favorite"
                        Click="AppBarButton_Click" />
        </utu:NavigationBar.PrimaryCommands>
      </utu:NavigationBar>

In VS Debug Ouput:

Workaround

N/A

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

Uno.Sdk: Reproducible in stable 5.4.10, but also with older versions like 5.3.31 for example.

Affected platforms

Android, iOS

IDE

Visual Studio 2022

IDE version

Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.11.4

agneszitte commented 2 hours ago

fyi @MartinZikmund, @kazo0

Related Discord comments for reference: https://discord.com/channels/1182775715242967050/1182775715729526908/1296641218482147338 https://discord.com/channels/1182775715242967050/1182775715729526908/1297733433015009300 https://discord.com/channels/1182775715242967050/1182775715729526908/1298433335907061760

WHL — 10/17/2024 9:09 PM Thanks for the update. There is another issue which is System.InvalidOperationException Message=The Dependency Property [UriSource] is owned by [Microsoft.UI.Xaml.Controls.BitmapIcon] and cannot be used on [Microsoft.UI.Xaml.Controls.FontIcon] WHL — 10/20/2024 9:29 PM This is error is for the PrimaryCommands, did not try it for MainCommand