Closed le-nn closed 1 year ago
That's an interesting use case.
Currently Navigation.PushAsync is equivalent to smth like that from Maui: Navigation.PushAsync(new PageNavigatedTo())
, i.e. it always creates a new page, in a separate blazor render tree. It doesn't re-use <ShellContent Title="Navigation"> <PageNavigatedTo /> </ShellContent>
in your Shell file.
I'll take a look whether it is possible to re-use cascading values from calling component (I doubt it that Blazor allows that, but not sure).
I'm thinking about your use case though. Would it work if you register Theme as a singleton in DI container instead of CascadingValue?
In my usecase,
If registering Singleton in DI instead of Cascading Param,
I should handle StatehasChanged
manually in every component with something like IObservable.
So, I need CascadingValue
. (ex: Changing the App Theme)
When route from nav menu button in Shell
with ShellContent
, it worked fine.
I see. Technically it is possible to handle StateHasChanged in root component only, but again - PushAsync currently creates a separate blazor tree, therefore there is no shared root component.
I will deal with using a state management library like Fluxor. Thanks.
@le-nn I'm thinking to add a support for layout components. While it doesn't make much sense to define markup there, but it might be useful for cascading values or error boundaries.
Do you think it would make sense from the perspective of this request?
OTOH, since adding a markup in a layout doesn't make any sense (and probably won't work at all), maybe it makes sense to create a similar concept with a different name to avoid confusion.
Cannot to get CascadingParam when naviated from INavigation.PushAsync<>()
AppShell
PageNavigateFrom
PageNavigateTo