标签: c# wpf silverlight prism mef
WPF Prism app的View在MEF容器的帮助下获取其ViewModel实例:
[Import] public MyModuleViewModel ViewModel { set { this.DataContext = value; } }
如何在View的代码隐藏中获取此VieModel实例的引用?
答案 0 :(得分:4)
var vm = DataContext as MyModuleViewModel;