ボタンがあります:
<sdk:Frame Margin="0,37,0,-15"
Source="/View/Login/LogIn.xaml">
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="/Login" MappedUri="/View/Login/LogIn.xaml" />
<uriMapper:UriMapping Uri="/Home" MappedUri="/View/Home.xaml" />
<uriMapper:UriMapping Uri="/AddPayment" MappedUri="/View/AddPayment.xaml" />
<uriMapper:UriMapping Uri="/Reports" MappedUri="/View/Reports.xaml" />
<uriMapper:UriMapping Uri="/Admin" MappedUri="/View/Admin.xaml" />
<uriMapper:UriMapping Uri="/Init" MappedUri="/View/Init.xaml" />
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
</sdk:Frame>
<HyperlinkButton Grid.Row="2" Grid.Column="1" Content="Log in" NavigateUri="/Home" Command="{Binding LoginCommand, NotifyOnValidationError=True}"/>
そしてビューモデル:
public RelayCommand LoginCommand
{
get
{
return this.loginCommand = new RelayCommand(param => this.LoginExecute(), param => (bool)this.CanLoginCommand);
}
}
private object CanLoginCommand
{
get
{
return true;
}
}
private void LoginExecute()
{
UserBag users = IsolatedStorageCacheManager<UserBag>.Retrieve(typeof(UserBag));
if (users != null && users.Users != null && users.Users.Any(u => u.UserName == this.login && u.Password == this.password))
{
}
else
{
throw new Exception("Bad password");
}
}
コマンドが例外を返すと、ビューに戻って表示され、ナビゲート uri が呼び出されないことが必要です。可能です?