AvaloniaUI / Avalonia.Samples

Avalonia.Samples aims to provide some minimal samples focusing on a particular issue at a time. This should help getting new users started.
https://www.avaloniaui.net
606 stars 103 forks source link

The first MVVM example has some problems #59

Open cbaugher opened 1 year ago

cbaugher commented 1 year ago

In step 3 it says to:

"Add the following code to the MainWindowViewlModel class in MainWindowViewModel.cs."

I think that should be MainViewModel class in MainViewModel.cs. There is no MainWindowViewModel class or .cs file.

In step 4: x:DataType="vm:MainWindowViewModel"

should be: x:DataType="vm:MainViewModel"

Also, there needs to be: xmlns:views="clr-namespace:BasicMvvmSample.Views"

somewhere before the Title line.

MainWindowViewModel is used in a few other places as well. Changing it to MainViewModel makes all the compile errors go away.

Unfortunately I'm now getting an error that says "A project with an Output Type of Class Library cannot be started directly." I understand what it's saying but I don't know how to fix it.

cbaugher commented 1 year ago

I got it to work even though there are still two errors. I had to set the startup project as "BasicMvvmSample.Desktop" (which I don't really understand), and then tell it to continue debugging even though there were errors.

This is really confusing. Lol

timunie commented 1 year ago

The issue here is that we have different templates in different IDEs now. I personally use Rider, which produces the files you see in the sample. Back when I wrote them, this was the same for VS. Now we have TemplateStudio which does it different. The idea is to have one project where you define the App and one or several projects for the OS you want to target. In your case desktop only, but Android could be added easily.

Will think about how to reflect it best in the samples and then update it. Thanks for sharing your feedback 🤗