UWP/MVVMlight:替换过时的ServiceLocator [英] UWP / MVVMlight : Replacing Obsolete ServiceLocator

查看:551
本文介绍了UWP/MVVMlight:替换过时的ServiceLocator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新我的应用程序,现在我使用MVVMLight 5.3.0 viewmodellocator在该行崩溃

I'm updating my apps and now I use MVVMLight 5.3.0 the viewmodellocator crash at the line

ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

我了解到,在最新版本的MVVMLight中,删除了servicelocartor类,并且Microsoft.Practices.ServiceLocation也消失了...

I read that ih the latest version of MVVMLight, the class servicelocartor is removed, And the Microsoft.Practices.ServiceLocation was gone ...

那么,我可以/必须做些什么才能使应用重新工作? 谢谢

So, what can/must i do for makes work the app again? Thanks

推荐答案

从介绍MVVMLight标准库版本的博客文章中,删除以下代码行:

From the blog post introducing the standard library version of MVVMLight, remove the line of code below:

// OLD ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

每当您使用ServiceLocator时,请使用SimpleIoc.Default代替.例如

Whenever you use the ServiceLocator.Current use SimpleIoc.Default instead. For example

// OLD var nav = ServiceLocator.Current.GetInstance<INavigationService>();
// NEW
var nav = SimpleIoc.Default.GetInstance<INavigationService>();

http://www.mvvmlight.net/std10

这篇关于UWP/MVVMlight:替换过时的ServiceLocator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆