그래서 Caliburn.Micro 및 바인딩 된 텍스트 상자로 작업 할 때 guard 절을 사용하려고했습니다.Guard 절을 실행하지 않음
보기 :
<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();
}
텍스트 상자에 타이핑을 시작한 후 어떤 이유로 가드 절이 발생하지 않습니다. 이는 내가 수행해야한다고 가정합니다. 어떤 아이디어?
아니요, 처음 시작할 때 (뷰가 인스턴스화 될 때), 그 다음에는 아무 것도 입력하지 않을 때, 포커스를 잃을 때가 아닙니다. ( – deanvmc
다른 제안을 추가했습니다 – maciejkow
완벽하게 작동합니다. 트리거를 변경 한 속성을 추가 할 필요가 없습니다. – deanvmc