Caliburn.Micro的保护条款出错

我正在尝试使用Caliburn.Micro实现这样的防护处理,但是当应用程序运行时我得到了一个无效的强制转换exception。

财产:

public Account UserAccount { get { return account; } set { account = value; NotifyOfPropertyChange(() => UserAccount); NotifyOfPropertyChange(() => CanSaveAndNavigateToComposeView()); } } 

方法:

  public void SaveAndNavigateToComposeView() { CommitAccountToStorage(); navigationService.UriFor().Navigate(); } 

守卫:

  public bool CanSaveAndNavigateToComposeView() { return !(string.IsNullOrEmpty(UserAccount.DisplayName) || string.IsNullOrEmpty(UserAccount.Username) || string.IsNullOrEmpty(UserAccount.Password) || string.IsNullOrEmpty(UserAccount.ServerSymbol)); } 

如果我取消对财产的通知道具更改,那么警卫就可以工作,但这意味着我的方法永远无法评估。

您需要将CanSaveAndNavigateToComposeView转换为属性而不是方法。