Provides platform independent navigation at the MVVM level and a Source Generator that automatically binds view and view models and registers this in your DI container ⭐ Last 10 features: - feat: Added BeforeInitializeComponent/AfterInitializeComponent partial methods when generating constructors. Fixed ViewModel init order. 2023-09-14 - feat: Now you can implement IActivatable for window/control and it will work. 2023-09-14 - feat: Implemented assembly:MapViews attribute. 2023-09-05 - feat: Added Activation support. 2023-09-04 - feat: Added separate property for InitializeComponent constructor. 2023-09-03 - feat: Released 0.2.0. 2023-09-03 - feat: Added Type markup extension. 2023-09-03 - feat: Added Properties.ViewModelType. 2023-09-02 - feat: Added HostApplicationBuilderExtensions. 2023-09-02 - feat: Removed Ioc.Default from main code. 2023-09-02 🐞 Last 10 bug fixes: - fix: Fixed work of ServiceLifetime.None. 2023-09-22 - fix: Fixed ViewLifetime/ViewModelLifetime. 2023-09-22 - fix: Fixed ViewModel/ViewModelType default binding mode. 2023-09-22 - fix: Removed views with ViewFor attribute from MapViews generation. Closes #6. 2023-09-17 - fix: Fixed issue with combined MapViews and ViewFor. 2023-09-16 - fix: Added try to resolve IResolver from Ioc.Default. 2023-09-15 - fix: Fixed ambiguities with resolver. 2023-09-14 - fix: Generated ViewModel property can be null now. 2023-09-12 - fix: Fixed problems with DependencyPropertyGenerator. 2023-09-11 - fix: Fixed "An expression is too long or complex to compile" in big projects. 2023-09-07
$ dotnet add package Mvvm.Navigation.UwpProvides platform independent navigation at the MVVM level and a Source Generator that automatically binds view and view models and registers this in your DI container.
.AddMvvmNavigation() call to your Host builder or IServiceCollection:public sealed partial class App
{
public App()
{
AppHost = Host
.CreateDefaultBuilder()
.AddMvvmNavigation()
.Build();
}
}using Mvvm.Navigation;
[ViewFor<MainViewModel>]
public partial class MainPage : UserControl;or assembly level attribute(nameof behavior is ignored and the full namespace is taken):
[assembly:MapViews(
viewsNamespace: nameof(MyNamespace.Views),
viewModelsNamespace: nameof(MyNamespace.ViewModels))]public Navigator<ObservableObject> Navigator { get; }<Grid>
<Button
Command="{Binding Navigator.NavigateByTypeCommand}"
CommandParameter="{x:Type viewModels:BlueViewModel}"
/>
<ContentControl mvvm:Properties.Navigator="{Binding Navigator}"/>
</Grid>Tip: you can use CommandParameter="{mvvm:Type Type=viewModels:BlueViewModel}" for WinUI/UWP/Uno platforms.
The library was written as a replacement for ReactiveUI in a real project,
and inherits some concepts from it, excluding reactivity.
If you have the same task, then the changes are as follows:
mvvm:Properties.ViewModel and mvvm:Properties.Resolver/mvvm:Properties.Navigator(includes resolver) attached dependency properties.Priority place for bugs: https://github.com/HavenDV/Mvvm.Navigation/issues
Priority place for ideas and general questions: https://github.com/HavenDV/Mvvm.Navigation/discussions
I also have a Discord support channel:
https://discord.gg/g8u2t9dKgE