mirror of https://github.com/AMT-Cheif/Stylet.git
Improve Stylet.Samples.Validation, and remove .TryClose
This commit is contained in:
parent
56395d8a8a
commit
a5f642d95c
|
@ -13,7 +13,7 @@ namespace Stylet.Samples.HelloDialog
|
|||
|
||||
public void Close()
|
||||
{
|
||||
this.TryClose(true);
|
||||
this.RequestClose(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<DockPanel LastChildFill="False">
|
||||
<TextBlock DockPanel.Dock="Bottom" HorizontalAlignment="Left" Width="{Binding ElementName=CustomAdorner, Path=ActualWidth}"
|
||||
Foreground="OrangeRed" TextTrimming="WordEllipsis"
|
||||
Text="{Binding ElementName=CustomAdorner,Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
|
||||
Text="{Binding ElementName=CustomAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
|
||||
<Border Background="OrangeRed" DockPanel.Dock="Right" Margin="5,0,0,0" VerticalAlignment="Top"
|
||||
Width="20" Height="20" CornerRadius="5">
|
||||
<TextBlock Text="!" VerticalAlignment="center" HorizontalAlignment="center" FontWeight="Bold" Foreground="white" />
|
||||
|
@ -53,19 +53,19 @@
|
|||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="0" Target="{Binding ElementName=UserName}">UserName:</Label>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" x:Name="UserName" Text="{Binding UserName}"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" x:Name="UserName" Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Target="{Binding ElementName=Email}">Email:</Label>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Email" Text="{Binding Email}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Email" Text="{Binding Email, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<Label Grid.Row="2" Grid.Column="0" Target="{Binding ElementName=Age}">Age:</Label>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" x:Name="Age" Text="{Binding Age}"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" x:Name="Age" Text="{Binding Age, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<Label Grid.Row="3" Grid.Column="0" Target="{Binding ElementName=Password}">Password:</Label>
|
||||
<PasswordBox Grid.Row="3" Grid.Column="1" x:Name="Password" xaml:Secure.Password="{Binding Password}"/>
|
||||
<PasswordBox Grid.Row="3" Grid.Column="1" x:Name="Password" xaml:Secure.Password="{Binding Password, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<Label Grid.Row="4" Grid.Column="0" Target="{Binding ElementName=PasswordConfirmation}">Password Confirmation:</Label>
|
||||
<PasswordBox Grid.Row="4" Grid.Column="1" x:Name="PasswordConfirmation" xaml:Secure.Password="{Binding PasswordConfirmation}"/>
|
||||
<PasswordBox Grid.Row="4" Grid.Column="1" x:Name="PasswordConfirmation" xaml:Secure.Password="{Binding PasswordConfirmation, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="0" IsChecked="{Binding ShouldAutoValidate}">Auto-Validate</CheckBox>
|
||||
<Button Grid.Row="5" Grid.Column="1" Command="{s:Action Submit}" HorizontalAlignment="Left">Submit</Button>
|
||||
|
|
|
@ -27,6 +27,10 @@ namespace Stylet.Samples.ModelValidation.Pages
|
|||
public UserViewModel(IWindowManager windowManager, IModelValidator<UserViewModel> validator) : base(validator)
|
||||
{
|
||||
this.windowManager = windowManager;
|
||||
// Force initial validation
|
||||
this.Validate();
|
||||
// Whenever password changes, we need to re-validate PasswordConfirmation
|
||||
this.Bind(x => x.Password, (o, e) => this.ValidateProperty(() => this.PasswordConfirmation));
|
||||
}
|
||||
|
||||
protected override void OnValidationStateChanged(IEnumerable<string> changedProperties)
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Stylet.Samples.RedditBrowser.Pages
|
|||
|
||||
public void GoBack()
|
||||
{
|
||||
this.TryClose();
|
||||
this.RequestClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ namespace Stylet.Samples.RedditBrowser.Pages
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.TryClose();
|
||||
this.RequestClose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
this.TryClose();
|
||||
this.RequestClose();
|
||||
}
|
||||
|
||||
public bool CanNext
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Stylet.Samples.RedditBrowser.Pages
|
|||
|
||||
// If we're setting the ActiveItem to null, that means everything's been closed - close ourselves
|
||||
if (newItem == null)
|
||||
this.TryClose();
|
||||
this.RequestClose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue