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 719 forks source link

Frame content does not render when using FeatureConfiguration.Frame.UseWinUIBehavior on android #18401

Open DavidM29 opened 2 weeks ago

DavidM29 commented 2 weeks ago

Current behavior

Frame content does not render when setting FeatureConfiguration.Frame.UseWinUIBehavior = true;.

Expected behavior

Content should get rendered.

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

UnoApp1.zip

Workaround

Have not found any workarounds yet.

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

No response

Affected platforms

Android

IDE

Visual Studio 2022

IDE version

17.11.4

Relevant plugins

No response

Anything else we need to know?

No response

MartinZikmund commented 1 week ago

After investigation I have found out the problem is that Uno.Toolkit automatically applies the NativeFramePresenter as the Frame template. This does not fare well with the WinUI Frame behavior, as that requires the Frame to manage Page instances and caching as compared to the frame presenter itself.

If you set UseWinUIBehavior to true on Android and iOS, you also need to override the default style for the control. You can do this by explicitly setting the Style to XamlDefaultFrame:

<Frame Style="{StaticResource XamlDefaultFrame}" />

Or by creating an implicit style based on XamlDefaultFrame:

<Style TargetType="Frame" BasedOn="XamlDefaultFrame" />