thoemmi / TinyLittleMvvm

A small MVVM library for WPF built on top of MahApps.Metro, supporting .NET Framework >= 4.7.2 and .NET Core >= 3
MIT License
131 stars 22 forks source link

Binding views to view models #34

Open abrasat opened 4 years ago

abrasat commented 4 years ago

First of all thank you for this very useful library. Is it possible with TinyLittleMvvm to assign views to view models also dynamically in the start-up code, instead of doing it statically in the xaml file? Would be possible to assign different instances of the same view-model to different views? Is there any schedule available for the release of a stable v2?

thoemmi commented 4 years ago

Is it possible with TinyLittleMvvm to assign views to view models also dynamically in the start-up code, instead of doing it statically in the xaml file? Would be possible to assign different instances of the same view-model to different views?

There's no mapping in the XAML files. In fact, by default TinyLittleMvvm takes the full name of the view model, replaces ViewModel with View, and gets an instance from the DI container. E.g. for the view model MyApp.ViewModels.MyViewModel, it will ask for an instance of MyApp.Views.MyView. You can customize it by changing ViewLocatorOptions, but still it only allows a mapping from view model type to view type.

What's you actual use case? Maybe we can find a solution.

Is there any schedule available for the release of a stable v2?

Well, as far as the code is concerned, it's ready for shipment. But I want to update the documentation before publishing it, as the API has changed significantly between v1 and v2.

abrasat commented 4 years ago

Thank you for the explanation. I dont have yet a concrete use case. I was trying to understand how the mapping between views and view models works in TinyLittleMvvm, and what possibilities does it offer to customize it if needed (maybe adding some sample code to your repository for such a scenario would help).

thoemmi commented 4 years ago

Yeah, documentation is on my list: #26