Repository navigation
Description
Current behavior
Listening to RouteNotifier as described in uno docs from MainModel as corresponding Model to MainPage where the apps NavigationView is placed, the output is case 1 empty string or case 2 "Tab" indicating the TabNavigationBar ib the bottom of this app, but never showing any of the route names in Route registry or xaml named regions.
Expected behavior
If that output would be the current route as expected it would maybe be possible to set the NavigationView Header Content to that Page Title=Route to not havong to add a header definition to each of them
How to reproduce it (as minimally and precisely as possible)
- Create a app using mvux, regions, DI with recommended template
- Set app.xaml.cs Route Registry:
ViewMap s for at least 3 pages incl. Their models, so add one - RouteMap:
Main is nested to shell, second and third page nested to main, second to be default, same as main. - Clear each pages current content
- Add NavigationView to MainPage, incl Region.Attached = true
- Add at least two menuitems NavigationViewItem s and add Region.Name to each of them to show the correct selection corresponding to shown content
- On the NavigationView properties place CommandExtensions.Command bound to MainModel to cantral navigation handler
- If you like to get some "Tab" output, add a TabNavigationBar with named Regions
- Add some simple content to the second and third page like a textblock with its name
- Install the IRouteNotifier exactly as told in documentation
- on route change let it set this text to MainModel
IState<string>CurrentHeaderText - bind this to the NavigationView.Header
Start and check it out. No header will be there
Environment
Nuget Package (s):
Package Version(s):
Affected platform(s):
- iOS
- macOS (AppKit)
- Mac Catalyst
- Android
- WebAssembly
- Windows
- Skia (WPF)
- Skia (GTK on Linux/macOS/Windows)
- Skia (Linux Framebuffer)
- Build tasks
Visual Studio:
- 2019 (version: )
- 2022 (version: latest)
- Visual Studio Code (version: )
- Rider Windows (version: )
- Rider macOS (version: )
Relevant plugins:
- Resharper (version: )
Anything else we need to know?
Would be nice to be able to set the NavigationView.Header to the current pages header or similar to not have to set this up at each page individually. On wpf or similar pages do have Title property to fill this in, on uno that is at least not available on intellisense...
Activity
DevTKSS commentedon Mar 4, 2025
Inspected the playground solution in this repo where this Interface is sampled. Will check its compatibility with a non shellmodel and check why that code in the docs is not working as expected
DevTKSS commentedon May 15, 2025
To get the actual Route by
IRouteNotifier.RouteChanged(object? sender, RouteChangedEventArgs args)the Event Property of Type IRegion.Name is not usable as shown in the Docs.After inspecting the src I would recommend to change IRegion Property to Route in general since that seems to be the meant task for this property? @MartinZikmund
@agneszitte For the docs to get the expected result of the How-To use
IRouteNotifierto Monitor Changes, we need to set it up like this e.g. in mvux:Page content used:
Visual Result from this implementation, which would be the actual expected Result in my opinion:
PS: you see the NavigationView Content initially empty, because I used HotReload to update the App. Filed this as Issue that navigator seems to have problems on having the nested Region Content again after Reloading, @nickrandolph told me there:
(??? since when is HotReload equal to HotDesign? just filed it there because I have been told HotReload and HotDesign are now both parts of "Studio")
maybe he missed my reply there, but in my understanding HotReload is defintly not in initial Release at all and to me the Navigator should be able to let us update the parented page and again insert the correct Region content while reloading.
Maybe this issue can get inspected again
@agneszitte let me know if you want to get the docs updated for IRouteNotifyer
DevTKSS commentedon May 19, 2025
Maybe this other issue could get resolved by the mentioned comlication also:
#2606
When I defined the eventhandler in line with using lambda instead of seperate function, which could get made async, I can agree that did not update the state it was requested to update!
kazo0 commentedon Jun 25, 2025
@DevTKSS sorry trying to follow up on this, is the issue here that the IRouteNotifier EventArgs are not being set properly or simply that we should update the docs to show it using
routeArgs.Navigator?.Routeinstead ofrouteArgs.Region?.Name?DevTKSS commentedon Jun 25, 2025
@kazo0
minimal:
updating the docs to tell us the working way for this, because the shown approach is not working for the result we are told to use it for
Better:
If the event arguments are useful for something else, please add this information additionally.
I don't know if the Route changed Event arguments should do this expected and that Region object not beeing useful for something else I don't know, then its up to you/Uno to take future steps 🤷
DevTKSS commentedon Jun 26, 2025
This linked would also add the appropriate xml comments we currently dont have for the
Route.ToString()overwrite to improve that In our IDEDevTKSS commentedon Aug 21, 2025
not in the docs but showed in my tutorial the How To to this 👍
https://youtu.be/RZ3RirA7jhk
@jeromelaban not sure if this makes it now state of "Fixed"? 😅 I mean for non German People its not correct in the docs 🤔 I could send a PR beginning of next month to update the docs, but I am not sure whats the reason, that we are until now are told to use the not-working approach. maybe this works only if its in App.xaml.cs or Shell but not on e.g. MainModel?
not sure...