You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ModularWpf is based off the CommunityToolkit.Mvvm package, a utility library that helps with modulation seperate parts of the WPF application.
Features
IServiceCollection extensions that help with registering common models of the MVVM pattern: AddView<TView, TViewModel>(), AddCachedView<TView, TViewModel>(), AddViewModel<TViewModel>()
Modular Windows - you can assign a Window object with a IModularWindow interface, then await the window and get the result via the service
myServiceCollection.AddModularWindow<MyModularWindow>();myServiceCollection.AddModularWindowsService();// OR if you dont want to register each window manually:myServiceCollection.AddModularWindows(assemblyFilter: a =>a==typeof(MyModularWindow).Assembly));// ! automatically registers the service as well !
Use-case
publicsealedpartialclassMyViewModel:ObservableObject{privatereadonlyIModularWindowsService_modularWindowsService;publicMyViewModel(IModularWindowsServicemodularWindowsService){_modularWindowsService=modularWindowsService;}[RelayCommand]privateasyncTaskOpenMyWindowAsync(){await_modularWindowsService.ShowWindowAsync<MyModularWindow>();}[RelayCommand]privateasyncTaskOpenMyWindowWithResultAsync(){// string is a result type that is defined in the IModularWindow<TResult> interface// regular IModularWindow doesnt have a return type, so in the implementation just keep it with the NotImplementedExceptionvarresult=await_modularWindowsService.ShowWindowAsync<MyModularWindow,string>();Console.WriteLine(result);}}
About
Comprehensive library with utilities to help you build a modular WPF application