[英]How to access locator that is created in App.xaml from the code?
In my App.xaml
the locator instance is created: 在我的
App.xaml
,创建了定位器实例:
<Application.Resources>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
</Application.Resources>
Now I would like to access Locator
object from ViewModel
. 现在,我想从
ViewModel
访问Locator
对象。 How can I refer to that object from the code? 如何从代码中引用该对象?
像这样:
var locator = (ViewModelLocator) Application.Current.Resources["Locator"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.