【发布时间】:2016-08-31 07:31:30
【问题描述】:
我最近开始使用 MVVM Light,并且是第一次使用 IDialogService。
我的 ViewModelLocator
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
// Register the dialog service provided by mvvm light
SimpleIoc.Default.Register<IDialogService, DialogService>();
我的视图模型
private IRestService _restService;
public OrderViewModel (IDialogService dialogService )
{
_dialogService = dialogService;
}
最后使用 ShowMessage:
await _dialogService.ShowMessage("test", "test", "Ok", "Nop", (result) => {
if (result)
{
//...
}
else
{
//...
}
});
导致此异常的原因:
Java.Lang.NullPointerException: Attempt to invoke virtual method
'android.content.res.Resources$Theme android.content.Context.getTheme()'
on a null object reference
谁能告诉我这是怎么回事?
【问题讨论】:
-
您的活动是否继承自 mvvm light 的
ActivityBase? -
请看我的回答
-
您是否启用了“仅我的代码”调试? social.technet.microsoft.com/wiki/contents/articles/…
标签: c# mvvm xamarin xamarin.forms mvvm-light