Reputation: 11
I'm creating WPF Core 3.1 app using Prism 7. In one of the view I am trying to register the view model for PRISM navigation through:
containerRegistry.RegisterForNavigation<ViewA, ViewAViewModel>();
And when required I do request to PRISM navigation service to navigate to the view using Region Manager
_regionManager.RequestNavigate(RegionNames.ContentRegion, "ViewA");
Navigation to the view is completed and I'm able to see the view on the defined region but the view model is not assigned to the view.
I tried to manually register the view model using the ViewModelLocationProvider but still the view model is not assigned.
ViewModelLocationProvider.Register<ViewA, ViewAViewModel>();
But if I use the PRISM Autowire property in the view then the view model is discovered and assigned to the view.
prism:ViewModelLocator.AutoWireViewModel="True"
View model class declared using IConfirmNavigationRequest interface required for navigation request handling
public class ViewAViewModel : RegionViewModelBase , IConfirmNavigationRequest
I am unable to figureout what I'm missing here.
Upvotes: 0
Views: 175
Reputation: 83
The only thing I see wrong is that you would need to use the interface INavigationAware
, not IConfirmNavigationRequest
. I assume RegionViewModelBase
implements BindableBase
already.
public class ViewAViewModel : RegionViewModelBase, INavigationAware
Upvotes: 1