【发布时间】:2011-10-06 20:26:32
【问题描述】:
我正在尝试使用 Caliburn.Micro 实现如此保护处理,但是当应用程序运行时我得到一个无效的强制转换异常。
房产:
public Account UserAccount
{
get
{
return account;
}
set
{
account = value;
NotifyOfPropertyChange(() => UserAccount);
NotifyOfPropertyChange(() => CanSaveAndNavigateToComposeView());
}
}
方法:
public void SaveAndNavigateToComposeView()
{
CommitAccountToStorage();
navigationService.UriFor<ComposeViewModel>().Navigate();
}
守卫:
public bool CanSaveAndNavigateToComposeView()
{
return !(string.IsNullOrEmpty(UserAccount.DisplayName) ||
string.IsNullOrEmpty(UserAccount.Username) ||
string.IsNullOrEmpty(UserAccount.Password) ||
string.IsNullOrEmpty(UserAccount.ServerSymbol));
}
如果我取出属性上的 notify 属性更改,守卫会起作用,但这意味着我的方法永远不会评估。
【问题讨论】:
标签: c# windows-phone-7 mvvm caliburn.micro