所以我一直在尝试让保护条款与 Caliburn.Micro 和绑定的文本框一起使用。
风景:
<TextBox x:Name="UserAccount_DisplayName" Margin="-10,-5,-10,8"/>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="False">
<shell:ApplicationBar.Buttons>
<cal:AppBarButton IconUri="\Resources\Iconography\appbar.check.rest.png"
Text="Save"
Message="SaveAndNavigateToAddAccountView" />
</shell:ApplicationBar.Buttons>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
视图模型:
public class EditAccountNameViewModel: PropertyChangedBase
public Account UserAccount
{
get
{
return account;
}
set
{
account = value;
NotifyOfPropertyChange(() => UserAccount);
NotifyOfPropertyChange(() => CanSaveAndNavigateToAddAccountView);
}
}
public bool CanSaveAndNavigateToAddAccountView
{
get
{
if (string.IsNullOrEmpty(UserAccount.DisplayName) == true)
{
return false;
}
return true;
}
}
public void SaveAndNavigateToAddAccountView()
{
CommitAccountToStorage();
navigationService.UriFor<AddAccountViewModel>().Navigate();
}
出于某种原因,在我开始输入文本框后,保护子句没有触发,这是我认为应该发生的。有任何想法吗?