0
votes

I have a WPF MVVM application using strongly-typed DataTemplates to represent the views for my view models. These DataTemplates are in resource dictionaries and automatically link up to the view models - standard stuff.

I want to fit Prism navigation to my app, but the navigation methods require a Uri for the view, which isn't part of this particular style of MVVM.

Can a region (on a ContentControl) simply navigate to a new view-model only?

Does Prism for WPF support this kind of view-less implementation

Thanks

1

1 Answers

1
votes

You could use the RegisterTypeForNavigation method to register the view model type for navigation with a unique name, for example in your bootstrapper class:

Container.RegisterTypeForNavigation<ViewAViewModel>("a");

You should then be able to use this name to navigate to it:

regionManager.RequestNavigate("YourRegionName", "a");

The view will be resolved as usual using DataTemplates, e.g.:

<ContentControl prism:RegionManager.RegionName="YourRegionName">
    <ContentControl.Resources>
        <DataTemplate DataType="{x:Type viewModels:ViewAViewModel}">
            <views:ViewA/>           
        </DataTemplate>
    </ContentControl.Resources>
</ContentControl>