简体   繁体   中英

Retrieve the ViewModel of a view in prism

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.

var viewModel = Page.BindingContext as MyViewModel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM