PkL728
PkL728

Reputation: 955

MVVMCross How does this View get linked to the ViewModel?

I'm trying to figure out why I get an error message about not being able to find the right ViewModel when I'm running my iOS app.

The question I have is when I look at this example I don't understand where MainMenuView gets bound to MainMenuViewModel.

Can someone answer this for me?

Thanks,

PkL728

Upvotes: 8

Views: 5542

Answers (4)

Dennis K
Dennis K

Reputation: 1878

For anyone who ends up here having the same problem I had. I was getting this error in an Android project because my (properly named) view was extending Activity and not MvxActivity (happens easily when you use Xamarin Studio's "Add Android Activity" feature)

Upvotes: 1

jyoung
jyoung

Reputation: 322

I'm getting this on a project that I've just upgraded to MvvmCross 4. I don't have much experience with MvvmCross, and the project hasn't been maintained for a few years, so it's possible something else is wrong.

I ended up hard coding the mappings in Setup::InitializeViewLookup because I don't have time to waste on it anymore.

Upvotes: 1

Vitalii Vasylenko
Vitalii Vasylenko

Reputation: 4896

Just want to add to the answer: double-check the names of the views after renaming (even Resharper renaming is not perfect). Spent several dozens of minutes (and a beer can), catching similar MvvmCross's error Could not find view for %ViewModelName%.

Upvotes: 1

Roman Kagan
Roman Kagan

Reputation: 464

They are bound by class names: for XXXView should be corresponded XXXViewModel

Upvotes: 9

Related Questions