You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
I set this <toolkit:StatusBarBehavior StatusBarColor="Fuchsia" StatusBarStyle="LightContent" /> on <ContentPage.Behaviors>...</ContentPage.Behaviors> and run this project on Android Emulator.
I got exception : System.NotImplementedException: 'Either set MainPage or override CreateWindow.'
But when I use default .NET MAUI project template and create a project, also add <toolkit:StatusBarBehavior StatusBarColor="Fuchsia" StatusBarStyle="LightContent" /> on <ContentPage.Behaviors>...</ContentPage.Behaviors> and run this project on Android Emulator, awesome, it is working fine.
How can I use ComminityToolkit's StatusBarBehavior on Prism.Maui project and have no exception?
@vulcanlee thanks for the detailed bug report. This appears to be an issue with the Community Toolkit however. The default Maui template uses Shell while Prism does not. It seems the behavior isn't compatible with non-Shell apps. If I had to guess the root cause of this is that MAUI has had a bug which I'm not sure that they fixed with the proper parenting of the root page when Shell isn't used. It's also possible this could be because Shell delays the creation of the Page so you already have a Window with a Parent.
Recreating what you had from a Maui template if you simply update the App's ctor
// MainPage = new AppShell();MainPage=new MainPage();
You'll actually see that this also fails and this is much closer to what Prism is doing with it's navigation. I would suggest opening an issue there as they can properly diagnose and fix the issue.
Today, I see this Announcing the .NET MAUI Community Toolkit v1.3 blog, then I create a MAUI Project by Prism.Maui Template and upgrade Prism.DryIoc.Maui to version 8.1.273-pre.
I set this
<toolkit:StatusBarBehavior StatusBarColor="Fuchsia" StatusBarStyle="LightContent" />
on<ContentPage.Behaviors>...</ContentPage.Behaviors>
and run this project on Android Emulator.I got exception : System.NotImplementedException: 'Either set MainPage or override CreateWindow.'
But when I use default .NET MAUI project template and create a project, also add
<toolkit:StatusBarBehavior StatusBarColor="Fuchsia" StatusBarStyle="LightContent" />
on<ContentPage.Behaviors>...</ContentPage.Behaviors>
and run this project on Android Emulator, awesome, it is working fine.How can I use ComminityToolkit's StatusBarBehavior on Prism.Maui project and have no exception?
The following reproduce projects are on https://github.com/vulcanlee/Prism-Fail-StatusBarBehavior
Using Maui Template to create App and can work with StatusBarBehavior
Open Visual Studio 2022
New Project
Select [.NET MAUI Application] template
Set project name is mauiTemplate
Create this Project
Install [CommunityToolkit.Maui] NuGet package into this project
Open [MauiProgram.cs] file, after
.UseMauiApp<App>()
, then add.UseMauiCommunityToolkit()
Open [MainPage.xaml]
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
<ScrollView>
element, add following XAMLRuning on Android emulator, it work fine.
Using Prism.Maui to create App and can not work with StatusBarBehavior
Open Visual Studio 2022
New Project
Select [Prism.NET MAUI App (Dan Siegel)] template
Set project name is prismTemplate
Create this Project
Install [CommunityToolkit.Maui] NuGet package into this project
Upgrade [Prism.DryIoc.Maui] NuGet package to version 8.1.273-pre
Open [MauiProgram.cs] file, find
.UsePrismApp<App>(PrismStartup.Configure)
, then replace with following C#xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
<ScrollView>
element, add following XAMLRuning on Android emulator, it got exception : System.NotImplementedException: 'Either set MainPage or override CreateWindow.'
I remark the
<ContentPage.Behaviors> ... </ContentPage.Behaviors>
XAML and re-run this project on Android emulator,The text was updated successfully, but these errors were encountered: