MVUX FAQ
This document answers frequently asked questions about MVUX
Can I use MVUX in combination with other MVVM frameworks?
Yes, you can use MVUX with MVVM, although it is not recommended. However, you can make it work by following these steps:
It is crucial to avoid having a
ViewModeland aModelwith the same name within the same namespace. For instance, havingMainModelandMainViewModelin the same namespace can lead to conflicts, as MVUX will generate its ownMainViewModelclass, which will clash with your existingMainViewModel.You need to turn off MVUX generation for your MVVM
ViewModelclasses by adding the attribute[ReactiveBindable(false)]to them.[ReactiveBindable(false)] public class MainViewModel { // ... }Note
In MVUX, the
ViewModelfor aModelis created when the class name matches the regex "Model$", this means any class that ends with "Model" will be considered aModelIf you are using the Uno Navigation Extensions, ensure you register your
MVVMViewModels in theApp.xaml.csfile with their correspondingPagetypes.private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes) { views.Register( new ViewMap<MainPage, MainViewModel>(), //Map MainPage to MainViewModel (MVVM) new DataViewMap<SecondPage, SecondModel, Entity>() //Map SecondPage to SecondModel (MVUX) ); routes.Register( new RouteMap("", View: views.FindByViewModel<ShellModel>(), Nested: [ new ("Main", View: views.FindByViewModel<MainViewModel>(), IsDefault:true), new ("Second", View: views.FindByViewModel<SecondModel>()), ] ) ); }
In the example above, the MainPage is mapped to the MainViewModel using MVVM, while the SecondPage is mapped to the SecondModel, which uses MVUX.
See the complete example here.
Important
You can implement the MVVM pattern manually or enable the Mvvm Uno Feature, which adds support for the CommunityToolkit.Mvvm package.