3

There is a way to retrieve the ViewModel of a view using prism ? I have a list of Views and I need get the ViewModel of this Views in code, I already linked the ViewModel to the view using this code line in the app.xaml.cs:

 ViewModelLocationProvider.Register<MyView, MyViewModel>(); 

But I didn't find a way to retrieve the ViewModel of a view using a prism or xamarin method.

1 Answer 1

5

var viewModel = Page.BindingContext as MyViewModel

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.