I want to implement the MVVM Light INavigationService interface in a DotVVM project; but I don't know how to do that. The most important method that I need to implement is NavigateTo(string pageKey) method.
I am using a SpaContentPlaceHolder in my MasterPage and I want to change the content (RouteName) of the SpaContentPlaceHolder by calling the NavigateTo method.
If you are in the viewmodel, you can just call
Context.RedirectToRoute("YourRoute", new { Param1 = something }).If you want to redirect from a different place, the easiest way is to create
INavigationServiceinterface and implement it to call the method onIDotvvmRequestContext(which is already registered in the ASP.NET Core dependency injection container):Then, you can just register the implementation as a scoped dependency in
Startup.csand you should be able to get it anywhere you need.