C# Caliburn.Micro的guard子句出错
我试图用Caliburn.Micro实现so防护处理,但当应用程序运行时,我得到一个无效的强制转换异常 财产:C# Caliburn.Micro的guard子句出错,c#,windows-phone-7,mvvm,caliburn.micro,C#,Windows Phone 7,Mvvm,Caliburn.micro,我试图用Caliburn.Micro实现so防护处理,但当应用程序运行时,我得到一个无效的强制转换异常 财产: public Account UserAccount { get { return account; } set { account = value; NotifyOfPropertyChange(()
public Account UserAccount
{
get
{
return account;
}
set
{
account = value;
NotifyOfPropertyChange(() => UserAccount);
NotifyOfPropertyChange(() => CanSaveAndNavigateToComposeView());
}
}
方法:
public void SaveAndNavigateToComposeView()
{
CommitAccountToStorage();
navigationService.UriFor<ComposeViewModel>().Navigate();
}
如果我在属性上进行notify道具更改,则该防护可以工作,但这意味着我的方法将永远无法评估。您需要将CanSave和NavigateToComposeView设置为属性而不是方法。为未来干杯!我希望这能成为正式文件。
public bool CanSaveAndNavigateToComposeView()
{
return !(string.IsNullOrEmpty(UserAccount.DisplayName) ||
string.IsNullOrEmpty(UserAccount.Username) ||
string.IsNullOrEmpty(UserAccount.Password) ||
string.IsNullOrEmpty(UserAccount.ServerSymbol));
}