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
Hi I'm having trouble working out how to use the INavigationService in MAUI. In Xamarin Forms we used to override PrepareViewFirst to inject the NavigationPageAdapter object into the container. In MAUI though PrepareViewFirst is never called when using DisplayRootViewForAsync.
Here's what I've got
public App()
{
InitializeComponent();
Initialize();
_container = container;
_container.PerRequest<HomeViewModel>();
_container.PerRequest<AnotherViewModel>();
DisplayRootViewForAsync<HomeViewModel>();
}
// This is never called so no NavigationService will not get added to the container
protected override void PrepareViewFirst(NavigationPage navigationPage)
{
_container.Instance<INavigationService>(new NavigationPageAdapter(navigationPage));
}
From looking at the source code I tried calling PrepareViewFirst() before DisplayRootViewForAsync and that successfully added a NavigationPageAdapter to the container however when INavigationService is injected into a viewmodel calling NavigateToViewModelAsync does nothing.
So how do we navigate between viewmodels in MAUI?
I'm using the latest beta version from MyGet
The text was updated successfully, but these errors were encountered:
Hi I'm having trouble working out how to use the
INavigationService
in MAUI. In Xamarin Forms we used to overridePrepareViewFirst
to inject theNavigationPageAdapter
object into the container. In MAUI thoughPrepareViewFirst
is never called when usingDisplayRootViewForAsync
.Here's what I've got
From looking at the source code I tried calling
PrepareViewFirst()
beforeDisplayRootViewForAsync
and that successfully added aNavigationPageAdapter
to the container however whenINavigationService
is injected into a viewmodel callingNavigateToViewModelAsync
does nothing.So how do we navigate between viewmodels in MAUI?
I'm using the latest beta version from MyGet
The text was updated successfully, but these errors were encountered: