Giter Club home page Giter Club logo

prism.maui's People

Contributors

chowarth avatar dansiegel avatar jbijsterboschnl avatar muak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prism.maui's Issues

[Proposal] Add Prism Bootstrapper

Description

While the App Builder is a necessary evil with .NET MAUI, it also means that you will end up with a potentially large MauiProgram file as you register various libraries such as the MAUI Community Toolkit, Telerik, Shiny, etc... On top of these you will have all of the services that you need to register for your application and any pages that you're registering for Navigation. To help move some of this into a separate file could be potentially helpful for some.

I am currently looking for community feedback on whether you would find this beneficial or whether it would just lead to a sense of confusion.

Proposal

Add an IPrismAppBuilderBootstrapper interface with methods defined matching what you might potentially call from the PrismAppBuilder. We can then add an abstract PrismBootstrapper which implements this interface making only the OnAppStart abstract and the rest of the methods virtual so that you only need to override the methods you want to make use of.

public interface IPrismAppBuilderBootstrapper
{
    void ConfigureServices(IServiceCollection services);

    void RegisterTypes(IContainerRegistry containerRegistry);

    void ConfigureLogging(ILoggingBuilder loggingBuilder);

    object ConfigureDefaultViewModelFactory(IContainerProvider container, object view, Type viewModelType);

    void ConfigureModuleCatalog(IModuleCatalog moduleCatalog);

    void OnInitialized(IContainerProvider container);

    Task OnAppStart(IContainerProvider container, INavigationService navigationService);
}

public abstract class PrismBootstrapper : IPrismAppBuilderBootstrapper
{
    public virtual object ConfigureDefaultViewModelFactory(IContainerProvider container, object view, Type viewModelType)
    {
        return PrismAppBuilder.DefaultViewModelLocator(view, viewModelType);
    }

    public virtual void ConfigureLogging(ILoggingBuilder loggingBuilder)
    {
    }

    public virtual void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
    {
    }

    public virtual void ConfigureServices(IServiceCollection services)
    {
    }

    public abstract Task OnAppStart(IContainerProvider container, INavigationService navigationService);

    public virtual void OnInitialized(IContainerProvider container)
    {
    }

    public virtual void RegisterTypes(IContainerRegistry containerRegistry)
    {
    }
}

This would then allow you to reference your Bootstrapper from the PrismAppBuilder like:

MauiApp.CreateBuilder()
    .UsePrismApp<App>()
    .ConfigureWithBootstrapper<Bootstrapper>()
    .ConfigureFonts(fonts => { 
        // your normal MauiAppBuilder code...
    })
    .Build();

Limitations

The Prism.Maui.Rx package exposes an extension on the PrismAppBuilder to access the IObservable<NavigationRequestContext> for a Global Handler. This would not be configurable in the Bootstrapper and would still need to be set using the PrismAppBuilder.

MAUI RC1 (VS2022 17.2.0 Preview 3.0): StackOverflow caused by recursion in PrismServiceProviderFactory.cs

Hi,
this is what I have tested so far:

  1. Install VS 2022 Version 17.2.0 Preview 3.0 (I have updated from the previous Preview)
  2. Clone Master Branch
  3. Update all NuGet packages
  4. Remove unnecessary entries from project file PrismMauiDemo.cs:
 <ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
    <!-- Required - WinUI does not yet have buildTransitive for everything -->
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
  </ItemGroup>
	
  <PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
    <OutputType>WinExe</OutputType>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>
	
  <ItemGroup>
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.1" />
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.2" />
  </ItemGroup>
  1. Remove line 49 in Prism.Maui\sample\PrismMauiDemo\Platforms\Windows\Package.appxmanifest:
    <uap:SplashScreen Image="Assets\appiconfgSplashScreen.png" />
  2. Rebuild Solution
  3. Run PrismMauiDemo
  4. The first problem is in Prism.Maui\src\Prism.Maui\Modularity\ModuleManager.cs
  5. LoadModules crashes with:
DryIoc.ContainerException: 'code: Error.RegisteringImplementationNotAssignableToServiceType;
message: Registering implementation type MauiModule.ViewModels.ViewAViewModel is not assignable to service type MauiModule.Views.ViewA.'
  1. Solution: See #6 (comment)
  2. The application now crashes with a stackoverflow in Prism.Maui\src\Prism.Maui\Ioc\PrismServiceProviderFactory.cs:
    internal class ServiceScopeFactory : IServiceScopeFactory
    {
        private IServiceProvider _services { get; }

        public ServiceScopeFactory(IServiceProvider services)
        {
            _services = services;
        }

        public IServiceScope CreateScope()
        {
            return _services.CreateScope();
        }
    }
  1. Reason: return _services.CreateScope() creates a new ServiceScopeFactory which causes the recursion

Now I'm stuck. If I could be of any help please let me know.

Best Regards
Uwe

Drop PrismApplication

Description

The Application really isn't needed by Prism with .NET MAUI. Everything that Prism made use of the Application for in Xamarin.Forms is either done with the App Builder or we have hooks in the Window which leaves the Application completely untouched. As a result this should be dropped completely. Any apps migrating will already need to be migrating their registration code to the App Builder there really isn't a reason to keep the PrismApplication class.

Automatic BindingContext not working when creating page in code behind.

Hello,

I have created a page in the code behind using :

MyPage myPage = new MyPage();
or
(MyPage)Activator.CreateInstance(typeof(MyPage));

When I check the binding context it is null.

I haven't added anything into the XAML as I know the AutowireViewModel is done by default now.
The binding context also successfully worked when I set the same page as a view inside of the tabbed page:

<NavigationPage Title="title">
    <x:Arguments>
        <Views:MyPage/>
    </x:Arguments>
</NavigationPage>

BindingContext also works when I navigate to the same page using navigateAsync.

Suggestion: Prism Maui removing Boilerplate commands + properties

Hi Dan,
Big fan of prism and the navigation service is the best there is , however I find quite appealing the use of MVVM toolkit especially the ability not to have boilerplates commands etc... using source generators

Do you think you would consider introducing something along those lines for prism Maui. I think that is missing link and what everyone is talking about and jumping on the MVVM toolkit bandwagon.

Great work!

Add DefaultView property for RegionManager

Description

Currently the RegionManager has a method RegisterViewWithRegion. This can be called in code to define any default views that should be populated in a Region with a given Name. There is however no current way to do this in XAML.

<ContentView prism:RegionManager.RegionName="MyRegion"
             prism:RegionManager.DefaultView="ViewA" />

Setting the AutowireViewModel attached property of the ViewModelLocator to the value Disabled ends up in runtime error

Setting the AutowireViewModel attached property of the ViewModelLocator to the value Disabled ends up in the below runtime error.

<ContentPage
    x:Class="MauiPrism.Views.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:prism="http://prismlibrary.com"
    prism:ViewModelLocator.AutowireViewModel="Disabled">
<!-- User-defined content -->
</ContentPage>

'Unable to cast object of type 'Prism.Mvvm.ViewModelLocatorBehavior' to type 'System.Nullable`1[System.Boolean]'.'

Extension method is missing from NuGet package

I have only created a new MAUI application and installed both Prism.Maui and Prism.DryIoc.Maui NuGet packages
I am gettinge an error

'MauiAppBuilder' does not contain a definition for 'UsePrismApp' and no accessible extension method 'UsePrismApp' accepting a first argument of type 'MauiAppBuilder' could be found (are you missing a using directive or an assembly reference?)
But I am sure I have added all the references. I have checked the code sample, and it is referencing the project directly.
Any suggestions please?

Migrate Navigation XAML Extensions

Description

There are a number of XAML Extensions for Navigation such as the Navigate & GoBack Extensions which have not yet been ported over to MAUI. These need to be migrated over.

NOT AN ISSUE but just a question about MAUI

Hey Daniel,
We love prism , can you give us a clue when we can have a Prism.Maui???

We want to move to MAUI , but we cannot even start as we are all in with Prism!!

Maui as you know will go live in a month , any plans? clues? anything?
Very grateful

thanks

Dialog doesn't appear when setting height and width

I am trying to open a dialog but when I set the height and width the dialog doesn't appear and I see only the gray background. Also a second problem I encountered is when I tap the background and the event is fired the application hangs.
I had the same implementation on Xamarin Forms and it was working fine.

Xaml Code

<?xml version="1.0" encoding="utf-8" ?>
<Frame x:Class="MyProject.Views.AddShoppingItemPopupPage"
       xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:prismDialog="clr-namespace:Prism.Services.Xaml;assembly=Prism.Maui"
       xmlns:local="clr-namespace:MyProject.ViewModels;assembly=DailyOrganizer"
       x:Name="AddShoppingItemPopup"
       prismDialog:DialogLayout.RelativeHeightRequest="0.5"
       prismDialog:DialogLayout.RelativeWidthRequest="0.9"
       BackgroundColor="#FAFAFA"
       Opacity="0">

    <prismDialog:DialogLayout.Mask>
        <BoxView
            x:Name="BG"
            BackgroundColor="Black"
            Opacity="0">
            <BoxView.GestureRecognizers>
                <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
            </BoxView.GestureRecognizers>
        </BoxView>
    </prismDialog:DialogLayout.Mask>

    <StackLayout Orientation="Vertical">
        <Label Text="Description"/>
        <Entry Text="{Binding ShoppingItem.Name}"/>

        <Label Text="Quantity"/>
        <Entry Text="{Binding ShoppingItem.Quantity}"/>

        <Button Text="Insert" Command="{Binding InsertNewShoppingItemCommand}"/>
    </StackLayout>
</Frame>

Code Behind

public partial class AddShoppingItemPopupPage
{
	public AddShoppingItemPopupPage()
	{
		InitializeComponent();
		AnimateAppearance();
	}

	private async Task AnimateAppearance()
	{
		await Task.Delay(125);
		AddShoppingItemPopup.FadeTo(1, 125);
		await BG.FadeTo(0.3, 250);
	}

	private async void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
	{
		await BG.FadeTo(0, 250);
		await AddShoppingItemPopup.FadeTo(0, 125);
	}
}

Dialog service

var result = await dialogService.ShowDialogAsync(nameof(AddShoppingItemPopupPage));

NavigationBuilder class scope

I would like to extend the NavigationBuilder class, but currently I cannot create subclasses because of the internal scope.
I would appreciate it if you could change the scope of the NavigationBuilder class to public.

If I can create subclasses, I will be able to complete this in individual projects without affecting the source code, such as #96 .

InitializeAsync is called twice.

When NavigationSegments is "/TabbedPage/NavigationPage/ContentPage",
InitializeAsync method is called twice in ContentPage's ViewModel implemented IInitializeAsync.

.OnAppStart((container,navigationService) =>
{
    navigationService.CreateBuilder()
    .AddTabbedSegment("MyTabbedPage", config =>
    {
        config
        .CreateTab(t => t.AddSegment<MyNavigationViewModel>().AddSegment<MainViewModel>())
    })
    .Navigate(HandleNavigationError);
})

In the following part, I call InitializeAsync of the child page of NavigationPage.

await MvvmHelpers.OnInitializedAsync(child, childParameters);

However, the following part also calls InitializeAsync for the child page of NavigationPage, so it is assumed to be duplicated.

await OnInitializedAsync(toPage, segmentParameters);

Make ViewModelLocator.Autowire property use an Enum Type

Description

When the Autowire property was initially introduced in Prism.Forms this was done as a boolean. This was later changed to a Nullable Boolean so that we could default the behavior to Autowire if you did not explicitly opt out. This behavior however creates certain issues where we may be resolving the ViewModel before the View is completely initialized by Prism.

The Updated NavigationRegistry & ViewModelLocationProvider2 in Prism.Maui allows for scenarios where you may have:

container.RegisterForNavigation<BillingPage, ShoppingCartViewModel>("ShoppingCart");
container.RegisterFroNavigation<BillingPage, SubscriptionsViewModel>("Subscriptions");

This further requires that Prism take additional steps to ensure that the ViewModelLocator resolves the correct ViewModel based on whether you navigated to the ShoppingCart or Subscriptions given the example above. To better facilitate this the Autowire property should be updated to use a ViewModelLocatorBehavior enum

public enum ViewModelLocatorBehavior
{
    Automatic,
    Disabled
}

This way the Navigation Service can evaluate the Page after resolution. If the behavior has been explicitly set to Disabled or if the Binding Context is not null then we will simply pass back the page... but if the Binding Context is null and the Behavior is Automatic then we will attach a property with the ViewModel type and call Autowire from the ViewModelLocationProvider2 which can let us pull the type from the Attached Property.

Roadmap for stable release?

Hi @dansiegel

Is there any rough ETA when Prism.Maui will be available in stable release? We have a large project that uses prism and are keen to get a bit of idea when we could shift to maui but that would depend on this library obviously.

Thank you in advance!

Why Error compiling Android/Windows (Release)

XAGJS7004 System.ArgumentException: [已添加了具有相同键的项。] 在 System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) 在 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) 在 Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, List1 javaTypes, String outputDirectory, ApplicationConfigTaskState appConfState) 在 Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types, TypeDefinitionCache cache) 在 Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res) 在 Xamarin.Android.Tasks.GenerateJavaStubs.RunTask() 在 Microsoft.Android.Build.Tasks.AndroidTask.Execute() 位置 /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:行号 17 MES C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.424\tools\Xamarin.Android.Common.targets 1442

Android Setting

Debug Mode compiling NoError

Navigation doesn't work on Windows

PrismMauiDemo sample on net6.0-windows target doesn't react when INavigationService.NavigateAsync is called and no error is written.

Strangely enough in another project I have at hand navigation pushes the page, but it always replaces the root NavigationPage, so no top bar with back button and page title is visible.

Steps to reproduce:

  1. Build and run sample
  2. Press on of the buttons

Regsitering Page and ViewModel gives DryIoc.ContainerException Error.RegisteringImplementationNotAssignableToServiceType

I routinely register Page and ViewModel explicitly in my code (please see attached project).
containerRegistry.RegisterForNavigation<ShoppingItemsPage, ShoppingItemsViewModel>();

Register failes with the following error:
DryIoc.ContainerException:
Error.RegisteringImplementationNotAssignableToServiceType;
Registering implementation type ShoppingListMaui.ViewModels.ShoppingItemsViewModel is not assignable to service type ShoppingListMaui.Views.ShoppingItemsPage.

When using only the Page:
containerRegistry.RegisterForNavigation<ShoppingItemsPage>();
the registration succeeds but the Navigation fails in PageNaviagtionService.GetPageFromWindow() with the
Sytem.InvalidOperationException "No page was set on the window."
Unfortunately this Function then silently returns null which causes that app to show no window and just hang around...:

PrismMauiIssueNavigation.zip

Prism Maui Dependency generates Global Usings

Hi, currently migrating my XF Project and I have the following error message

Error CS8370 Feature 'global using directive' is not available in C# 7.3. Please use language version 10.0 or greater. Futura.IA.CuratedShoppingModule (net6.0) D:\...Futura.IA.CuratedShoppingModule.GlobalUsings.g.cs

My csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <UseMaui>true</UseMaui>
    <TargetFrameworks>net6.0</TargetFrameworks>
    <OutputType>Library</OutputType>
  </PropertyGroup

I can workaround the issue by changing my csproj to this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <UseMaui>true</UseMaui>
    <TargetFrameworks>net6.0</TargetFrameworks>
    <OutputType>Library</OutputType>
    <ImplicitUsings>disable</ImplicitUsings>
    <LangVersion>10.0</LangVersion>
    <UseMaui>true</UseMaui>
  </PropertyGroup>

Now ... im not sure why I have to add LangVersion to make the error disapear. But when I disable the implicit usings then my msbuild is still creating a global using file with prism namespaces. Is this intended?

global using global::Prism;
global using global::Prism.AppModel;
global using global::Prism.Commands;
global using global::Prism.Events;
global using global::Prism.Ioc;
global using global::Prism.Modularity;
global using global::Prism.Mvvm;
global using global::Prism.Navigation;
global using global::Prism.Regions;
global using global::Prism.Regions.Navigation;
global using global::Prism.Services;

Issue when I install Prims.Maui

Hello, i'm trying to install the beta of Prism.Maui.
I install the package with the package manager (Install-Package Prism.Maui -Version 8.1.191-beta) and after that, I tried the MapAppBuilder :

namespace MauiApp1;
using Prism;

public static class MauiProgram
{
	public static MauiApp CreateMauiApp()
	{
            var builder = MauiApp.CreateBuilder();
            return builder.UsePrismApp<App>(prism => {
            
            });
        }
}

And I have an error :
None of the specified arguments matches the parameter 'configurePrism' of 'PrismAppBuilderExtensions.UsePrismApp<TApp>(MauiAppBuilder, IContainerExtension, Action<PrismAppBuilder>)'
I dont know what to do, did I miss something ?

Thank's a lot

Add Support for Tab Deep Linking

Description

Currently the Dynamic Tab Creation is quite limited, however we want to update this so that we can create deep links within the context of the createTab query parameter. This should itself maintain the ability for segments to have their own query parameters which requires proper URI Encoding from the NavigationBuilder.

Example

A typical Deep Link might look something like:

NavigationPage/ViewA?id=3/ViewB?title=Ice%20Cream/ViewC?message=Hello%20Prism%20Navigation

In the event that we support Deep Linked Tab Creation we might have:

TabbedPage?createTab=NavigationPage%2FViewA%3Fid%3D3%2FViewB%3Ftitle%3DIce%2520Cream%2FViewC%3Fmessage%3DHello%2520Prism%2520Navigation

This becomes an ideal spot to use the NavigationBuilder as this takes the complexity required for the Navigation URI and simplifies it into something that is much easier to read & understand:

Navigation.CreateBuilder()
    .AddTabbedSegment(builder =>
        builder.CreateTab(tab =>
            tab.AddNavigationPage()
                .AddNavigationSegment("ViewA", segment => segment.AddSegmentParameter("id", 5)) // id=5 only passed to ViewA
                .AddNavigationSegment("ViewB", segment => segment.AddSegmentParameter("title", "Ice Cream")) // title=Ice Cream only passed to ViewB
                .AddNavigationSegment("ViewC", segment => segment.AddSegmentParameter("message", "Hello Prism Navigation")))) // message only passed to ViewC
    .AddParameter("Foo", "Bar"); // passed in INavigationParameters to all pages... not via querystring

Toolbar item icons do not update when navigating back

When navigating back from a page that includes toolbar items to a page that includes toolbar items, the toolbar item icons shown on the second page show on the first page.

Steps to reproduce

Create an application with multiple pages, say MainPage and Page2.
Add a toolbar item to MainPage with Text.
Add a toolbar item to Page2 with an IconImageSource.

Start the application on Android.
Observe the toolbar item.
image

Navigate to Page2
Observe the toolbar items
image

Press the back button in the toolbar on Page2 to navigate back to MainPage.
Observe the toolbar item on MainPage is now the same toolbar item that was on Page2.
image

Expected outcome: The MainPage toolbar item is the original MainPage toolbar item
Actual outcome: The MainPage toolbar item changes to the toolbar item from Page2.

Affected platforms

Prism 8.1.273-pre

Android is affected
Windows is not.
I am unable to test on iOS.

I'm using Visual Studio Professional Version 17.3.1

Reproduction project

Prism.Maui toolbar item icons issue.zip

This solution contains two projects MauiApp1 and PrismMauiApp2 with the same basic application described in the repro steps.
MauiApp1 is a Maui shell app. The issue is not observed with this project.
PrismMauiApp2 is a Prism.Maui app. The issues is observed with this project.

[BUG] Absolute navigation not updating 'Application.Current.MainPage' in Android in .Net MAUI

Description

When doing absolute navigation with '/' in .NetMaui prism, Application's current page's MainPage property is not updated to the latest page.

It is working fine with iOS.

Code
await navigationService.NavigateAsync($"/{nameof(AbsolutePage)}");

While doing this navigation following property [Application.Current.MainPage] is not updated with AbsolutePage it is showing value of old page.

Steps to Reproduce

  1. Create a maui app solution
  2. Configure with prism
  3. Do navigation with absolute navigation [await navigationService.NavigateAsync($"/{nameof(AbsolutePage)}");] from MainPage
  4. Verify Application.Current.MainPage property, it should be updated with latest page AbsolutePage.

Platform with bug

.NET MAUI

Affected platforms

Android

Did you find any workaround?

No response

Relevant log output

No response

Where is Prism.Maui -- When will the Beta be on NuGet.org

I'm leaving this here so that I do not continually get this question.

Sponsors

First and foremost I want to emphasize that for those of you who are active GitHub Sponsors, or who would like to become one and help support my efforts with Prism.Maui, each build from the PRs merged here are available immediately on the Sponsor Connect NuGet feed. For those of you who keep telling me that "I need to get Prism.Maui out because your business needs it", do remember you have the capability of making a one time or recurring Sponsorship up to $12,000. Such sponsorships would help to ensure that I can dedicate more time to Prism.Maui and help you get what you need out faster.

Public Beta

Regarding a publicly available Beta, it is planned. No I cannot give you an exact date, honestly I would have thought it would be up by now.

As many of you may know the Prism Library is leaving the .NET Foundation. As a result of Code Signing the NuGet packages that Prism has been doing for several years at the request of the Foundation, we will no longer be able to upload packages to NuGet.org once we leave. In order to continue to upload new builds, we have to get an updated Code Signing Certificate and update our CI Build to sign our NuGet packages for upload. This is something that we are actively working on, however going through the verification for the updated Code Signing Certificate is taking longer than initially planned. As this is something that we need to do for Prism, the Prism.Maui repo will be the first to implement these changes and serve as the proving ground to validate our updated build for the main Prism repo.

Is the Beta ready for Production

As of right now, probably not. Frankly even MAUI itself still has a number of bugs, and that number is only going to increase as libraries like Prism begin to probe MAUI's capabilities and as developers begin working through Proof of Concepts. There are still several known API's that have not been ported from Prism.Forms. Some like the Dialog Service will likely need some significant thought behind them in order to take advantage of MAUI's Window API. Others may be fairly straight forward, while yet others probably just got missed by accident.

I do encourage people to play around with the Prism.Maui API, find & report known bugs, do please contribute where you can whether it's docs, samples, or PRs to fix bugs or bring over missing APIs.

Multiple issues with modal navigation

Problem 1: Navigation service is unable to perform modal navigation.

Attempting to navigate to a modal page using the following code snippet performs modeless navigation instead:

// Navigate to the modal page
await _navigationService.CreateBuilder()
    .AddNavigationPage(useModalNavigation: true)
    .AddSegment<ModalPageViewModel>()
    .NavigateAsync();

This is due to the code that determines the value of useModalNavigation being commented out in PageNavigationService.ProcessNavigation. Uncommenting this line resolves the issue:

protected virtual async Task ProcessNavigation(Page currentPage, Queue<string> segments, INavigationParameters parameters, bool? useModalNavigation, bool animated)
{
    ...

    //var useModalNavigation = pageParameters.ContainsKey(KnownNavigationParameters.UseModalNavigation) ? pageParameters.GetValue<bool>(KnownNavigationParameters.UseModalNavigation) : false;

    ...
}

Problem 2: Navigation service is unable to return from modal navigation page.

Attempting to return from the previous modal page using the following code snippet fails:

// Close the modal page
await _navigationService.GoBackAsync();
[DOTNET] Navigation: GoBack
[DOTNET] Result: Failed
[DOTNET] Cannot GoBack from NavigationPage Root.

This is due to PageNavigationService.GoBackModal returning false when it should return true. I believe the following code should check if navPage.Parent is a PrismWindow instead of an Application. Changing this line resolves the issue:

private bool GoBackModal(NavigationPage navPage)
{
    ...

    else if (navPage.CurrentPage == navPage.RootPage && navPage.Parent is Application && rootPage != navPage)
        return true;

    ...
}

Support Multiple Regions on a Page

Description

While Prism "Technically" supports multiple regions on a single page, there is currently a bug in which we expose an attached property to contain any children which normal Navigation interfaces should also attempt to execute on. Currently we are simply proving a binding for a Region's Active Views. This however means that the last Region initialized will be the only region with supported views.

Proposal

Introduce a new IEnumerable that supports registering an individual View or IRegion. The IEnumerable should return all Active Views from all Regions plus any registered Views.

Select Tab from one of the child page.

Hi,

Is it possible to select the tab from child page inside a tab. e.g

3 tabs in Root (Tab1, Tab2, Tab3)

Page Stack in Tab1 is : Tab1 > View A > View B > Goto Tab3

I tried looking into documentation couldn't find anything for Prism.MAUI. I created the tabs like this.

/TabbedPage?createTab=NavigationPage|Tab1&amp;createTab=NavigationPage|Tab2&amp;createTab=NavigationPage|Tab3
Is it possible to select Tab3 from View B?

"selectedTab=Tab3" is not working. I am getting the below exception when trying it.


[DOTNET] Navigation: app://prismapp.maui/TabbedPage?selectedTab=Tab2
[DOTNET] Result: Failed
[DOTNET] Object reference not set to an instance of an object.
[DOTNET] System.NullReferenceException: Object reference not set to an instance of an object.
[DOTNET]    at Prism.Navigation.PageNavigationService.OnNavigatedTo(Page toPage, INavigationParameters parameters) in /_/src/Prism.Maui/Navigation/PageNavigationService.cs:line 734
[DOTNET]    at Prism.Navigation.PageNavigationService.DoNavigateAction(Page fromPage, String toSegment, Page toPage, INavigationParameters parameters, Func`1 navigationAction, Action`1 onNavigationActionCompleted) in /_/src/Prism.Maui/Navigation/PageNavigationService.cs:line 701
[DOTNET]    at Prism.Navigation.PageNavigationService.ProcessNavigationForRootPage(String nextSegment, Queue`1 segments, INavigationParameters parameters, Nullable`1 useModalNavigation, Boolean animated) in /_/src/Prism.Maui/Navigation/PageNavigationService.cs:line 457
[DOTNET]    at Prism.Navigation.PageNavigationService.ProcessNavigation(Page currentPage, Queue`1 segments, INavigationParameters parameters, Nullable`1 useModalNavigation, Boolean animated) in /_/src/Prism.Maui/Navigation/PageNavigationService.cs:line 346
[DOTNET]    at Prism.Navigation.PageNavigationService.NavigateAsync(Uri uri, INavigationParameters parameters) in /_/src/Prism.Maui/Navigation/PageNavigationService.cs:line 295

Cannot use SkiaSharp.Extended.UI.Maui to show Lottie animation

I watch and follow this video Implement Lottie Animations in .NET MAUI Under 10 Minutes!
that create .NET MAUI project, add a dotnetbot.json which is Lottie file and can work fine and can see Lottie animation on the App.

When I create MAUI project by [Prism .NET MAUI App (Dan Siegel)] template and do same things as above, I cannot see Lottie animation. But when I modify this project that does not use .UsePrismApp<App>(PrismStartup.Configure) method call and change to .UseMauiApp<App>(), the Lottie animation work fine.

Following is my test video recording

https://vulcanfiles.blob.core.windows.net/$web/Share/2022/Prism.Maui%20Lottie%20Problem.mp4

My test project source repo as following

https://github.com/vulcanlee/Prism-MAUI-Lottie

Absolute Navigation hack for Android results in an extra Window causing other side effects

When using absolute navigation this results (at least on Android) in a 2nd window being added. This should not be the case I guess?

After researching the code, I've found an Android hack for absolute navigation which is causing this (in PageNavigationService.DoPush() at line 913).

Reproduction steps:

  1. Open the Prism.Maui demo app
  2. Replace the OnAppearing() implementation for:
public async void OnAppearing()
{
    await Task.Delay(3000);

    await _navigationService.CreateBuilder()
        .AddNavigationSegment<RootPageViewModel>()
        .UseAbsoluteNavigation()
        .NavigateAsync();

    await Task.Delay(10000);

    var windowsCount = Application.Current?.Windows.Count;
}
  1. Run the code and check/debug windowsCount (it is 2 where it shouldn't)

After changing the PageNavigationService, removing the Android hack it seems not to happen. Perhaps the .NET MAUI bug is resolved in the stable release?

@dansiegel do you have a (unit) test/scenario where this hack was needed for? Could you perhaps validate removing this hack is possible here? I'll create a pull request for the code change so you are able to validate this.

View Registry

Description

Prism.Forms has always had a Static NavigationRegistry. This Registry has been there in part to help with mapping Views <---> ViewModels. This also has been a source of pain in Unit Testing as the NavigationRegistry may have the wrong static context if it was not cleared from one test to the next. While Prism.Maui has made a number of improvements around the NavigationRegistry the static nature still remains and is duplicated for Regions. These static APIs should be removed in preference for using the DI Container.

Registration

When Registering a View for Navigation a ViewRegistration instance should be registered along with the View Type & ViewModel Type if specified. The ViewRegistration already exists in Prism.Maui.

Changes

A new ViewType should be added to the ViewRegistration so that we can better filter

public enum ViewType
{
    Page,
    Dialog,
    Region,
}

We can then define a common IViewRegistry & ViewRegistryBase which can be reused for Page Navigation, Regions, & Dialogs.

public interface IViewRegistry
{
    IEnumerable<ViewRegistration> Registrations { get; }

    object CreateView(IContainerProvider container, string name);

    Type GetViewType(string name);

    string GetViewModelNavigationKey(Type viewModelType);

    IEnumerable<ViewRegistration> ViewsOfType(Type baseType);

    bool IsRegistered(string name);
}

More Encapsulated App Builder

As Posted by @JeremyBP. The idea is to move the AppBuilder to a delegate call inside of UsePrismApp thereby more clearly showing what is part of the Prism configuration vs Maui.

I wonder if we could get something more "encapsulated" to follow kind of separation of concerns, like:

MauiApp.CreateBuilder()
    .UsePrismApp<App>(prismBuilder => prismBuilder
            .ConfigureStartup<PrismStartup>()
            .AddGlobalNavigationObserver(context => context.Subscribe(x => {
                 // your exception handling logic
            }))
            .AddOtherPrismRelatedAwesomeFeature())
    .ConfigureFonts(fonts => { 
        // your normal MauiAppBuilder code...
    })
    .AddOtherMauiRelatedCoolFeature()
    .Build();

I mean everthings Prism related available into the UsePrismApp extension thanks to a PrismAppBuilder Action parameter, and UsePrismApp extension itself returning the original MauiAppBuilder.
Don't know if it would be cleaner/easier or not... just wondering :)

Originally posted by @JeremyBP in #43 (comment)

Add support for Prism Dialogs

Description

While some of the code is present the Prism DialogService needs to be fully ported and implemented for Prism.Maui

Prism.Maui cannot work with ComminityToolkit's StatusBarBehavior

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

    the version is 1.3

  • Open [MauiProgram.cs] file, after .UseMauiApp<App>() , then add .UseMauiCommunityToolkit()

  • Open [MainPage.xaml]

    • Add new namespace : xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
    • before <ScrollView> element, add following XAML
<ContentPage.Behaviors>
    <toolkit:StatusBarBehavior StatusBarColor="Fuchsia" StatusBarStyle="LightContent" />
</ContentPage.Behaviors>
  • Runing 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

    the version is 1.3

  • 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#

.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.UsePrism(prism=>
{
    prism.OnAppStart("MainPage");
    prism.RegisterTypes(containerRegistry =>
    {
        containerRegistry.RegisterForNavigation<MainPage>()
                        .RegisterInstance(SemanticScreenReader.Default);
    });
})
  • Open [Views] > [MainPage.xaml]
    • Add new namespace : xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
    • before <ScrollView> element, add following XAML
<ContentPage.Behaviors>
    <toolkit:StatusBarBehavior StatusBarColor="Fuchsia" StatusBarStyle="LightContent" />
</ContentPage.Behaviors>
  • Runing 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,

Hot Reload does not work with project created from Prism Maui Template

Steps to reproduce on windows 10, visual studio 2022 preview:

  1. Create a new Project using the Prism Maui Template
  2. Start running the project on a local android device, in debug mode.
  3. Visual Studio's Xaml Hot Reload gives a message saying "Failed to Initialize":
    image
  4. Changes text of a label on the MainPage.xaml does not trigger hot reload changes on device

Local Android device used:

  • Samsung A32
  • OS version: 12

Unhandled managed exception: Unable to resolve service for type 'Prism.Ioc.IContainerExtension' on Mac

I just tried to install the package, but can not run the app. Help me fix this issue.

**

IDE: Visual Studio 2022 Preview 2 for Mac
.NET MAUI v0.9.0.0
.NET SDK - Workloads (6.0.100-rc.2.21505.57)

✔ android-aot (Microsoft.NET.Sdk.Android.Manifest-6.0.100 : 
31.0.101-preview.9.16) installed.
✔ ios (Microsoft.NET.Sdk.iOS.Manifest-6.0.100 : 15.0.101-preview.9.31) 
installed.
✔ maccatalyst (Microsoft.NET.Sdk.MacCatalyst.Manifest-6.0.100 : 
15.0.101-preview.9.31) installed.
✔ tvos (Microsoft.NET.Sdk.tvOS.Manifest-6.0.100 : 15.0.101-preview.9.31) 
installed.
✔ macos (Microsoft.NET.Sdk.macOS.Manifest-6.0.100 : 12.0.101-preview.9.31) 
installed.
✔ maui (Microsoft.NET.Sdk.Maui.Manifest-6.0.100 : 6.0.101-preview.9.1843) 
installed.
✔ wasm-tools (microsoft.net.workload.mono.toolchain.manifest-6.0.100 : 
6.0.0-rc.2.21480.5) installed.
✔ microsoft-net-sdk-emscripten 
(microsoft.net.workload.emscripten.manifest-6.0.100 : 6.0.0-rc.2.21474.1) 
installed.

The log:

Unhandled managed exception: Unable to resolve service for type 'Prism.Ioc.IContainerExtension' while attempting to activate 'TestMaui.App'. (System.InvalidOperationException)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type , CallSiteChain , ParameterInfo[] , Boolean )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache , Type , Type , CallSiteChain )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor , Type , CallSiteChain , Int32 )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type , CallSiteChain )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type , CallSiteChain )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type , CallSiteChain )
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type )
at System.Collections.Concurrent.ConcurrentDictionary2[[System.Type, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Func2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope, Microsoft.Extensions.DependencyInjection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(Type , Func`2 )
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type , ServiceProviderEngineScope )
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type )
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider , Type )
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredServiceIApplication
at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions)
--- End of stack trace from previous location ---
at UIKit.UIApplication.Main(String[] , Type , Type )
at TestMaui.Program.Main(String[] args) .../Platforms/iOS/Program.cs:line 15

Btw, When do we have a release for Prism.Unity.Maui?

Error: "Method not found: Microsoft.Maui.Hosting.IAppHostBuilder"

Hello, I am trying to implement Prism.Maui a test Maui project. I have installed Prism.DryIoc.Maui 8.1.27-alpha from Nuget. My implement codes is located below. When I debug project to Android Emulator I am getting error. I think I am overlooking some things. Thank you in advance.

Error
System.MissingMethodException: 'Method not found: Microsoft.Maui.Hosting.IAppHostBuilder Microsoft.Maui.Hosting.AppHostBuilderExtensions.UseMauiApp<!0>(Microsoft.Maui.Hosting.IAppHostBuilder)'

Error

Startup.cs

using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using Prism;

namespace MauiTest
{
    public class Startup : IStartup
    {
        public void Configure(IAppHostBuilder appBuilder)
        {
            appBuilder
                .UsePrismApplication<App>(x => x.UseDryIoc())
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                });
        }
    }
}

App.cs

using Microsoft.Maui;
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
using Prism;
using Prism.Ioc;
using Prism.Navigation;
using System.Threading.Tasks;

namespace MauiTest
{
    public partial class App : PrismApplication
    {
        public App(IContainerExtension container)
            : base(container)
        {
        }
        
        protected async override Task OnWindowCreated(IActivationState activationState)
        {
            Microsoft.Maui.Controls.Compatibility.Forms.Init(activationState);

            this.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>()
                .SetImageDirectory("Assets");

            await NavigationService.NavigateAsync("/MainPage");
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterForNavigation<MainPage>();
        }
    }
}

App.xaml


<prism:PrismApplication xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
			 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
			 xmlns:local="clr-namespace:MauiTest"
             xmlns:prism="clr-namespace:Prism;assembly=Prism.Maui"
			 x:Class="MauiTest.App">
    <prism:PrismApplication.Resources>
        <ResourceDictionary>
            <Color x:Key="PageBackgroundColor">#512bdf</Color>
            <Color x:Key="PrimaryTextColor">White</Color>

            <Style TargetType="Label">
                <Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" />
                <Setter Property="FontFamily" Value="OpenSansRegular" />
            </Style>

            <Style TargetType="Button">
                <Setter Property="TextColor" Value="{DynamicResource PrimaryTextColor}" />
                <Setter Property="FontFamily" Value="OpenSansRegular" />
                <Setter Property="BackgroundColor" Value="#2b0b98" />
                <Setter Property="Padding" Value="14,10" />
            </Style>

        </ResourceDictionary>
    </prism:PrismApplication.Resources>
</prism:PrismApplication>

GoBack to View Name

Description

While we currently support GoBack (1 page)... or GoBackToRoot (within a NavigationPage). There may be times where you simply want to pop the stack to a specified point. For instance if you have a navigation Stack like:

ViewA/ViewB/ViewC/ViewD/ViewE when going back from ViewE you may simply want to go back to ViewB which is neither the root or a single page back.

This will add an overload that will continue navigating back until a specified page is found in the Navigation Stack.

public interface INavigationService
{
    // API Added
    Task<INavigationResult> GoBackAsync(string name, INavigationParameters parameters);
}

NullReferenceException on Windows with UseMauiCompatibility

Hi I'm experiencing NullReferenceException on Windows with following stack trace if I add UseMauiCompatibility() to the app builder

I had opened issue in the MAUI repo first, but couldn't replicate it there until I looked at the code and realized that Prism Ioc must be involved dotnet/maui#7949

 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Window.ThisPtr.get()	Unknown
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Window.operator ==(Microsoft.UI.Xaml.Window x = {Microsoft.UI.Xaml.Window}, Microsoft.UI.Xaml.Window y = null)	Unknown
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Window.operator !=(Microsoft.UI.Xaml.Window x = {Microsoft.UI.Xaml.Window}, Microsoft.UI.Xaml.Window y = null)	Unknown
 	Microsoft.Maui.Controls.Compatibility.dll!Microsoft.Maui.Controls.Compatibility.Forms.SetupInit(Microsoft.Maui.IMauiContext mauiContext = {Microsoft.Maui.MauiContext}, Microsoft.UI.Xaml.Window mainWindow = {Microsoft.UI.Xaml.Window}, System.Collections.Generic.IEnumerable<System.Reflection.Assembly> rendererAssemblies = null, Microsoft.Maui.Controls.Compatibility.InitializationOptions? maybeOptions = {Microsoft.Maui.Controls.Compatibility.InitializationOptions})	Unknown
 	Microsoft.Maui.Controls.Compatibility.dll!Microsoft.Maui.Controls.Compatibility.Forms.Init(Microsoft.Maui.IActivationState state = {Microsoft.Maui.ActivationState}, Microsoft.Maui.Controls.Compatibility.InitializationOptions? options = {Microsoft.Maui.Controls.Compatibility.InitializationOptions})	Unknown
 	Microsoft.Maui.Controls.Compatibility.dll!Microsoft.Maui.Controls.Compatibility.Hosting.AppHostBuilderExtensions.OnConfigureLifeCycle.AnonymousMethod__1_0(Microsoft.UI.Xaml.Application app = {PrismMauiDemo.WinUI.App}, Microsoft.UI.Xaml.LaunchActivatedEventArgs args = {Microsoft.UI.Xaml.LaunchActivatedEventArgs})	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.MauiWinUIApplication.OnLaunched.AnonymousMethod__2(Microsoft.Maui.LifecycleEvents.WindowsLifecycle.OnLaunching del = {Method = {System.Reflection.RuntimeMethodInfo}})	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents<Microsoft.Maui.LifecycleEvents.WindowsLifecycle.OnLaunching>(System.IServiceProvider services, System.Action<Microsoft.Maui.LifecycleEvents.WindowsLifecycle.OnLaunching> action = {Method = {System.Reflection.RuntimeMethodInfo}})	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.MauiWinUIApplication.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args = {Microsoft.UI.Xaml.LaunchActivatedEventArgs})	Unknown
 	PrismMauiDemo.dll!PrismMauiDemo.WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args = {Microsoft.UI.Xaml.LaunchActivatedEventArgs}) Line 26	C#
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args = {Microsoft.UI.Xaml.LaunchActivatedEventArgs})	Unknown
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(System.IntPtr thisPtr, System.IntPtr args)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj = {WinRT.ObjectReference<WinRT.Interop.IUnknownVftbl>}, Microsoft.UI.Xaml.ApplicationInitializationCallback callback = {Method = {System.Reflection.RuntimeMethodInfo}})	Unknown
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback = {Method = {System.Reflection.RuntimeMethodInfo}})	Unknown
 	PrismMauiDemo.dll!PrismMauiDemo.WinUI.Program.Main(string[] args = {string[0]}) Line 31	C#

Questions about AppShell

If you use AppShell, the structure of the ioc will be broken, and the ViewModel cannot be obtained correctly in ShellContent

Current Code does not build in 17.2 Preview 5

Hi,
thank you very much for the merge. Unfortunately there is a bug in Preview 5 that causes libraries with UseMaui=true to fail during build with the following message:
C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.300-rc.2.5513\Sdk\WinUI.NetCore.targets(188,5): error MSB4057: The target "CopyLocalFilesOutputGroup" does not exist in the project.

For "Full" Maui-Libraries (that have full platform support) it is possible to update the csproj file to the new format:

        <TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
        <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
        <!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->

and

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>

This doesn't seem to work if the library is just using Net-6.0 and UseMaui=true. Maybe this needs to be reported to the Maui-Team, because they think modifying the project file solves the issue...

Do you see this behaviour as well?

Add support for IApplicationLifecycleAware

There is currently no support for IApplicationLifecycleAware within Prism.Maui as there was in Prism.Forms.

This would be really useful so that views/viewmodels can be notified of the application lifecycle events.

Maui documentation for reference: App Lifecycle

NullReferenceException WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs) in Windows Maui Preview 10

Prism.Maui preview 9 worked well with Maui preview 9. After updating to Maui preview 10 WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs) in App.xaml.cs (Windows platform) throws null reference exception. Was there a breaking change?

System.NullReferenceException

  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=WinRT.Runtime
  StackTrace:
   at WinRT.IInspectable..ctor(IObjectReference obj)
   at Microsoft.UI.Xaml.Window.<.ctor>b__21_0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.UI.Xaml.Window.get__default()
   at Microsoft.UI.Xaml.Window.get_DispatcherQueue()
   at Microsoft.Maui.Controls.Compatibility.Forms.SetupInit(IMauiContext mauiContext, Window mainWindow, IEnumerable`1 rendererAssemblies, Nullable`1 maybeOptions)
   at Microsoft.Maui.Controls.Compatibility.Forms.Init(IActivationState state, Nullable`1 options)
   at Microsoft.Maui.Controls.Hosting.AppHostBuilderExtensions.<>c.<OnConfigureLifeCycle>b__1_0(Application app, LaunchActivatedEventArgs args)
   at Microsoft.Maui.MauiWinUIApplication.<>c__DisplayClass1_0.<OnLaunched>b__0(OnLaunching del)
   at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action`1 action)
   at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
   at MauiApp2.WinUI.App.OnLaunched(LaunchActivatedEventArgs args) in C:\Users\vikto\source\repos\MauiApp2\MauiApp2\Platforms\Windows\App.xaml.cs:line 29

  This exception was originally thrown at this call stack:
    [External Code]
    MauiApp2.WinUI.App.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs) in App.xaml.cs

Global Navigation Event Handler

Description

Due to Navigation being Page based with Xamarin.Forms -> .NET Maui, the Navigation Service has a hard requirement that it can not be a Singleton. This creates a complication as there has been no good way of dealing with Navigation on a global basis. While the Page based navigation requirement is not changing, what we can do is expose NavigationEvent that can be published with Prism's IEventAggregator. Consuming applications can then either listen for and respond to the event. We could also introduce a plugin package to wrap this into an IObservable. As the event would contain the full context of the navigation this would also help us to ensure that you could maintain the current Navigation Uri.

Proposal

public enum NavigationType
{
    Navigate,
    GoBack,
    GoToRoot,
}

public record NavigationContext
{
    public NavigationType Type { get; init; }
    // Only has a value when NavigationType is Navigate
    public Uri? RequestUri { get; init; }
    public INavigationParameters Parameters { get; init; }
    public INavigationResult Result { get; init; }
}

public class NavigationEvent : PubSubEvent<NavigationContext> { }

Implementation

Currently Prism's Navigation Service has a number of places where we return the INavigationResult typically something like:

return new NavigationResult { Success = true };

This would be updated to call a helper method which would return the NavigationResult and publish the event something like:

// Called by GoBack & GoToRoot
protected INavigationResult Notify(NavigationType type, INavigationParameters parameters, INavigationResult result)
{
    _ea.GetEvent<NavigationEvent>().Publish(new NavigationContext
    {
        Type = type,
        Parameters = parameters,
        Result = result,
    });
    return result;
}

// called by Navigate
protected INavigationResult Notify(Uri uri, INavigationParameters parameters, INavigationResult result)
{
    _ea.GetEvent<NavigationEvent>().Publish(new NavigationContext
    {
        Type = NavigationType.Navigate,
        RequestUri = uri,
        Parameters = parameters,
        Result = result,
    });
    return result;
}

PrismMauiDemo

I downloaded the demo on August 13 and built with sdk 6.0.400 and Visual Studio 17.3.0. The demo work perfectly with android devices, but it dos not seem to work at all with Windows. IN windows I managed to see some pages when I changed the absolute address with a relative one (see attached file). I hope it can help
RootPage.txt
p

ContainerLocator.Current returns null in App that uses Maui Preview 9 / VS 2022 Preview 5

I have compiled the Preview 8 branch of Prism.Maui and made the necessary changes for Preview 9 (adding "using Microsoft.Maui.Hosting;").
In my project I have referenced to compiled assemblies (Prism.Maui.dll, Prism.DryIoc.Maui.dll) and I have added the Prism.Core Nuget (8.1.97).
My problem is that in PrismApplication:

   protected PrismApplication()
    {
        _containerExtension = ContainerLocator.Current;
        ConfigureViewModelLocator();
    }

ContainerLocator.Current returns null. It does work in the Prism Demo App. App.Xaml and App.Xaml.cs are identical in both projects and platforms (Windows).

Please find attached both solutions as a zip file. For space reasons I have removed the obj and bin folders.

Do you have any idea what I am missing here?

Thanks in advance for any help

repos.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.