{"id":15409980,"url":"https://github.com/havendv/mvvm.navigation","last_synced_at":"2025-04-19T07:13:09.962Z","repository":{"id":191853541,"uuid":"678342876","full_name":"HavenDV/Mvvm.Navigation","owner":"HavenDV","description":"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","archived":false,"fork":false,"pushed_at":"2025-02-03T06:23:53.000Z","size":1126,"stargazers_count":21,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T12:55:55.202Z","etag":null,"topics":["binding","csharp","dependency-injection","di","dotnet","generator","mvvm","net6","net7","source","source-generator","view","viewmodel"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HavenDV.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-14T10:32:00.000Z","updated_at":"2025-02-28T02:19:22.000Z","dependencies_parsed_at":"2023-09-01T05:51:15.691Z","dependency_job_id":"4b0026df-2cf5-4b4c-9e73-8b1cebadbd40","html_url":"https://github.com/HavenDV/Mvvm.Navigation","commit_stats":{"total_commits":179,"total_committers":2,"mean_commits":89.5,"dds":"0.25698324022346364","last_synced_commit":"021a18c4b245c698b8f897d8dcf73281825b84c6"},"previous_names":["havendv/mvvm.navigation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FMvvm.Navigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FMvvm.Navigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FMvvm.Navigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HavenDV%2FMvvm.Navigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HavenDV","download_url":"https://codeload.github.com/HavenDV/Mvvm.Navigation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249191210,"owners_count":21227520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binding","csharp","dependency-injection","di","dotnet","generator","mvvm","net6","net7","source","source-generator","view","viewmodel"],"created_at":"2024-10-01T16:42:11.404Z","updated_at":"2025-04-19T07:13:09.944Z","avatar_url":"https://github.com/HavenDV.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Mvvm.Navigation](https://github.com/HavenDV/Mvvm.Navigation/) \n\n[![CI/CD](https://github.com/HavenDV/Mvvm.Navigation/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/HavenDV/Mvvm.Navigation/actions/workflows/dotnet.yml)\n[![License: MIT](https://img.shields.io/github/license/HavenDV/Mvvm.Navigation)](https://github.com/HavenDV/Mvvm.Navigation/blob/main/LICENSE.txt)\n[![Discord](https://img.shields.io/discord/988253265550532680?label=Discord\u0026logo=discord\u0026logoColor=white\u0026color=d82679)](https://discord.gg/g8u2t9dKgE)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Core.svg?style=flat-square\u0026label=Mvvm.Navigation.Core)](https://www.nuget.org/packages/Mvvm.Navigation.Core/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Wpf.svg?style=flat-square\u0026label=Mvvm.Navigation.Wpf)](https://www.nuget.org/packages/Mvvm.Navigation.Wpf/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Uno.svg?style=flat-square\u0026label=Mvvm.Navigation.Uno)](https://www.nuget.org/packages/Mvvm.Navigation.Uno/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Uno.WinUI.svg?style=flat-square\u0026label=Mvvm.Navigation.Uno.WinUI)](https://www.nuget.org/packages/Mvvm.Navigation.Uno/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Uwp.svg?style=flat-square\u0026label=Mvvm.Navigation.Uwp)](https://www.nuget.org/packages/Mvvm.Navigation.Uwp/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.WinUI.svg?style=flat-square\u0026label=Mvvm.Navigation.WinUI)](https://www.nuget.org/packages/Mvvm.Navigation.WinUI/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Avalonia.svg?style=flat-square\u0026label=Mvvm.Navigation.Avalonia)](https://www.nuget.org/packages/Mvvm.Navigation.Avalonia/)\n[![NuGet](https://img.shields.io/nuget/dt/Mvvm.Navigation.Maui.svg?style=flat-square\u0026label=Mvvm.Navigation.Maui)](https://www.nuget.org/packages/Mvvm.Navigation.Maui/)\n\nProvides platform independent navigation at the MVVM level and \na Source Generator that automatically binds view and view models and \nregisters this in your DI container.  \n  \n## 🔥Features🔥\n- Uses DI to resolve your view from view model.\n- Generates constructors for your views(optional).\n- Generates an extension method for you with all your Views and ViewModels to register them in DI.\n- Does not contain custom controls, everything happens based on the attached dependency property and does not limit the user.\n- Allows forward/backward navigation like in Chrome.\n- Allows you to receive activation/deactivation events - just implement IActivatableViewModel for your ViewModel.\n- Allows you to generate a typed ViewModel property via an attribute, bound to your BindingContext and initialized from DI.\n- Supports automatic mapping between View and ViewModel based on a global attribute.\n- Allows case-by-case, attribute-based control for Views.\n\n## Usage\n1. Add `.AddMvvmNavigation()` call to your Host builder or `IServiceCollection`:\n```csharp\npublic sealed partial class App\n{\n    public App()\n    {\n        AppHost = Host\n            .CreateDefaultBuilder()\n            .AddMvvmNavigation()\n            .Build();\n    }\n}\n```\n2. Add ViewFor attribute to your views:\n```csharp\nusing Mvvm.Navigation;\n\n[ViewFor\u003cMainViewModel\u003e]\npublic partial class MainPage : UserControl;\n```\nor assembly level attribute(nameof behavior is ignored and the full namespace is taken):\n```csharp\n[assembly:MapViews(\n    viewsNamespace: nameof(MyNamespace.Views),\n    viewModelsNamespace: nameof(MyNamespace.ViewModels))]\n```\nor in .csproj:\n```xml\n\u003cItemGroup Label=\"Navigation\"\u003e\n    \u003cAssemblyAttribute Include=\"Mvvm.Navigation.MapViews\"\u003e\n        \u003c_Parameter1\u003enameof(MyNamespace.Views)\u003c/_Parameter1\u003e\n        \u003c_Parameter1_IsLiteral\u003etrue\u003c/_Parameter1_IsLiteral\u003e\n        \u003c_Parameter2\u003enameof(MyNamespace.ViewModels)\u003c/_Parameter2\u003e\n        \u003c_Parameter2_IsLiteral\u003etrue\u003c/_Parameter2_IsLiteral\u003e\n        \u003cViewLifetime\u003eMvvm.Navigation.ServiceLifetime.Transient\u003c/ViewLifetime\u003e\n        \u003cViewLifetime_IsLiteral\u003etrue\u003c/ViewLifetime_IsLiteral\u003e\n        \u003cViewModelLifetime\u003eMvvm.Navigation.ServiceLifetime.Scoped\u003c/ViewModelLifetime\u003e\n        \u003cViewModelLifetime_IsLiteral\u003etrue\u003c/ViewModelLifetime_IsLiteral\u003e\n    \u003c/AssemblyAttribute\u003e\n\u003c/ItemGroup\u003e\n```\nDefault lifetime is `ServiceLifetime.Transient` for View and `ServiceLifetime.Scoped` for ViewModel.\n3. Add Navigator to your ViewModel:\n```csharp\npublic Navigator\u003cObservableObject\u003e Navigator { get; }\n```\n4. Add commands to your views(or just use Navigator from ViewModel):\n```xml\n\u003cGrid\u003e\n    \u003cButton\n        Command=\"{Binding Navigator.NavigateByTypeCommand}\"\n        CommandParameter=\"{x:Type viewModels:BlueViewModel}\"\n        /\u003e\n    \u003cContentControl Content=\"{Binding Navigator.CurrentView}\"/\u003e\n\u003c/Grid\u003e\n```\nTip: you can use `CommandParameter=\"{mvvm:Type Type=viewModels:BlueViewModel}\"` for WinUI/UWP/Uno platforms.\n\n## Base\nThe library was written as a replacement for ReactiveUI in a real project, \nand inherits some concepts from it, excluding reactivity.  \nIf you have the same task, then the changes are as follows:\n- Replace RoutingState with Navigator\n- Replace IScreen with INavigable\n- Replace ReactiveUserControl with UserControl\n- Replace ReactiveWindow with Window\n- Replace RoutedViewHost and ViewModelViewHost with ContentControl\n- Use `mvvm:Navigation.ViewModel` and `mvvm:Navigation.Navigator`(includes ServiceProvider) attached dependency properties.\n- Or just bind like this `\u003cContentControl Content=\"{Binding Navigator.CurrentView}\"/\u003e`\n\n## Support\nPriority place for bugs: https://github.com/HavenDV/Mvvm.Navigation/issues  \nPriority place for ideas and general questions: https://github.com/HavenDV/Mvvm.Navigation/discussions  \nI also have a Discord support channel:  \nhttps://discord.gg/g8u2t9dKgE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavendv%2Fmvvm.navigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhavendv%2Fmvvm.navigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavendv%2Fmvvm.navigation/lists"}