caz162
caz162

Reputation: 35

Prism bind TabViews to respective ViewModels

I am migrating a legacy Xamarin.Forms app to a MAUI project. In the Xamarin Project we were using Prism 7.1 which we are now migrating to the latest version.

The issue we are having is we used to be able to use ViewModelLocator.AutowirePartialView to bind SyncFusion TabViews to their respective ViewModels.

For example we have a MainPage that we have a SFTabView within it. This TabView has ViewA, ViewB and ViewC as tabs. Each of these are ContentViews and have their own ViewModels (ViewAViewModel, ViewBViewModel, ViewCViewModel).

Each ViewModel has its own logic about bindings and which URLs to contact. We do not want this in the MainPageViewModel.

Having removed the ViewModelLocator.AutowirePartialView from each view it no longer binds to the correct ViewModel. Instead it binds to the MainPageViewModel.

Looking at the documentation it appears that when using a TabbedPage, we should navigate to it with the CreateTab parameters. That's fine when using the native TabbedPage but what about when using a 3rd Party component?

Is the new approach to use Regions?

Upvotes: 0

Views: 194

Answers (1)

Brundha
Brundha

Reputation: 1

The concept of Prism's regions, which are used for rendering other ContentViews, is currently not available in the context of Maui Prism. When examining the Prism library, it is currently empty. Therefore, it is unable to locate the appropriate 'Regions' NuGet package for .NET MAUI platforms.

Maui Prism Regions link: https://prismlibrary.com/docs/maui/regions/index.html

Upvotes: 0

Related Questions