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

*xaml.cs files in the demo application #36

Closed abrasat closed 4 years ago

abrasat commented 4 years ago

Could you please explain why there are no corresponding xaml.cs files for the different view .xaml files from the demo application? I am looking for the *.cs files with the definitions of the different classes referenced from the different views.

thoemmi commented 4 years ago

IMHO if you follow the MVVM pattern in the most strict way, views should not need any code behind. All logic shoudl go to the view models. That's why I delete all *.xaml.cs files. What kind of information are you missing?

abrasat commented 4 years ago

I tried to add an additional window to the demo, for example with an OxyPlot inside (I added also the corresponding view model). I got compiler errors saying that the view model cannot be found (although intellisense showed the name of the view model class when editing the xaml file). I must say I did not work by now with Metro controls, maybe my missing knowledge is the problem. I dont know for example if a user control is needed for this, or if it is possible to place an OxyPLot component inside a Metro window.

thoemmi commented 4 years ago

I don't know what compiler error you're getting. TinyLittleMvvm tries to get the matching the vew model at run time, not compile time. Have you added the types to the dependency injection container?

If you publish a simple repository for reproduction, I might try to help you.

abrasat commented 4 years ago

Yes, all the types are added. The error occurs at some point in visual studio 2019 xaml designer, not sure when exactly. It does not seem to be related to a specific xaml, it occured today for an "original" window from the demo application. Rebuilding the project did not help.

xaml_design_err

thoemmi commented 4 years ago

That issue has nothing do to with TinyLittleMvvm. The d:DataContext attribute is used by the XAML designer to provide intellisense for the bindings.

But I can see in your screenshot that you have entered a double colon, ViewModels::SampleDialogViewModel. Only a single colon is required.

abrasat commented 4 years ago

Oh, you are right, I did not notice that. I got now the demo working again, also with my additional window. Thanks for your help.