Navigation - cant go back in basic MainPage / SecondPage scenario , what am I doing wrong ? #2301
Replies: 4 comments 7 replies
-
Hi @DomagojJugovich, as you mentioned here unoplatform/uno#16586 (reply in thread) I think it would be helpful if you could share your solution if possible. cc @nickrandolph |
Beta Was this translation helpful? Give feedback.
-
In commerce example and in default tempates there is aproximately ShellPage->MainPage->SecondPage. So why it works that way, why is shellpage needed, or to rephrase why first loaded page is not in back history ? Thx again. |
Beta Was this translation helpful? Give feedback.
-
@nickrandolph this.Navigator().NavigateRouteAsync(this, "Navigation", data : inventura); In that moment I get these events on NavigationPage :
And OnNavigatedTo is not called any more. Also I see when navigating from page that DataContext is set to null again. Here is a route configuration to see that NavigationPage, NavigationViewModel is associated corectly in ViewMap and called by route "Navigation". private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
views.Register(
new ViewMap(ViewModel: typeof(ShellViewModel)),
new ViewMap<MainPage, MainViewModel>(),
new ViewMap<InventuraPage, InventuraViewModel>(),
new ViewMap<PostavkePage, PostavkeViewModel>(),
new ViewMap<NavigationPage, NavigationViewModel>(),
new ViewMap<LokacijePage, LokacijeViewModel>(),
new ViewMap<InventuraOrgjPage, InventuraOrgjViewModel>(),
new ViewMap(View: typeof(InventuraSveStavkePage)),
new ViewMap<InventuraChartsPage, InventuraChartsViewModel>(),
new ViewMap<InventuraNedefiniraneStavkePage, NedefiniraneStavkeViewModel>(),
new ViewMap<InventuraRashodPage, InventuraRashodViewModel>()
//new DataViewMap<SecondPage, SecondViewModel, Entity>()
);
routes.Register(
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(),
Nested: new RouteMap[]
{
new RouteMap("Main", View: views.FindByViewModel<MainViewModel>()),
new RouteMap("Inventura", View: views.FindByViewModel<InventuraViewModel>()),
new RouteMap("Postavke", View: views.FindByViewModel<PostavkeViewModel>()),
new RouteMap("Navigation", View: views.FindByViewModel<NavigationViewModel>()),
new RouteMap("Lokacije", View: views.FindByViewModel<LokacijeViewModel>()),
new RouteMap("Orgj", View: views.FindByViewModel<InventuraOrgjViewModel>()),
new RouteMap("SveStavke", View: views.FindByView<InventuraSveStavkePage>()),
new RouteMap("Charts", View: views.FindByViewModel<InventuraChartsViewModel>()),
new RouteMap("NedefiniraneStavke", View: views.FindByViewModel<NedefiniraneStavkeViewModel>()),
new RouteMap("Rashod", View: views.FindByViewModel<InventuraRashodViewModel>())
}
)
);
} Please, please help ! |
Beta Was this translation helpful? Give feedback.
-
Back to App with Nav Ext , test without nesting : routes.Register(
new RouteMap("", View: views.FindByViewModel<ShellViewModel>()),
new RouteMap("Main", View: views.FindByViewModel<MainViewModel>()),
new RouteMap("Inventura", View: views.FindByViewModel<InventuraViewModel>()),
new RouteMap("Postavke", View: views.FindByViewModel<PostavkeViewModel>()),
new RouteMap("Navigation", View: views.FindByViewModel<NavigationViewModel>()),
new RouteMap("Lokacije", View: views.FindByViewModel<LokacijeViewModel>()),
new RouteMap("Orgj", View: views.FindByViewModel<InventuraOrgjViewModel>()),
new RouteMap("SveStavke", View: views.FindByView<InventuraSveStavkePage>()),
new RouteMap("Charts", View: views.FindByViewModel<InventuraChartsViewModel>()),
new RouteMap("NedefiniraneStavke", View: views.FindByViewModel<NedefiniraneStavkeViewModel>()),
new RouteMap("Rashod", View: views.FindByViewModel<InventuraRashodViewModel>()) there is no change , on NavigationPage DataContextChanged is called 3 times : ShellViewModel, NULL, NavigationViewModel. |
Beta Was this translation helpful? Give feedback.
-
I migrated oldour old UNO app, but I created new project/solution with newest templates for UnoSDK / WinUI only, and migrated all may code and files. By that I migrated to Uno SDK, single project and WinUI at once. So it should be clean from inconsistency problems.
All UWP to WinUI tidbits are solved and app runs (first screen loads), Desktop head works, Android works.
So navigation is not working how it worked before, so I looked at tutorials and reworked to :
I have no RegisterRoutes for now, as I see that is not important.
I am trying very simple scenario just to go to other page and back.
I am not able to go back ! ****
I registered event on PostavkePage (think secondPage):
This event fires on android emulator hw button, so that part works. But CanGoBack is false, even if I ignore that and fire NavigateBackAsync nothing happens.
To see how new extension works with navigation I found that best example is commerce app in uno examples so I used that as a guideline.
In App.xml.cs I tried only first line or only second line , it doesn't make a difference , second line I found in commerce example :
//Host = await builder.NavigateAsync();
Host = await MainWindow.InitializeNavigationAsync(async () => builder.Build(), new MainPage());
I watched all techbites, all available documentation, but how navigations works "under the hood" is a mystery to me, will look at the source code of uno navigation extension later.
Also in commerce app I saw how to log debug details of navigation extension so here it is :
Beta Was this translation helpful? Give feedback.
All reactions