StyletWpfExamples/StyletFirstValidation/Views/UserView.xaml

63 lines
3.5 KiB
XML

<UserControl x:Class="StyletFirstValidation.Views.UserView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:local="clr-namespace:StyletFirstValidation.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="CommonStyle" TargetType="{x:Type Control}">
<Setter Property="Margin" Value="10,5,0,5"/>
<Setter Property="FontSize" Value="12" />
</Style>
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource CommonStyle}"/>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource CommonStyle}"/>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource CommonStyle}"/>
</UserControl.Resources>
<Grid Margin="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="0" Grid.Column="2" Grid.RowSpan="5">
<ListBox ItemsSource="{Binding ErrorsCollection}" Background="Red">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=.}" Foreground="White"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
<Label Grid.Row="0" Grid.Column="0" Target="{Binding ElementName=txtUserName}">UserName:</Label>
<TextBox Grid.Row="0" Grid.Column="1" x:Name="txtUserName" Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="1" Grid.Column="0" Target="{Binding ElementName=txtEmail}">Age:</Label>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="txtAge" Text="{Binding Age, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="2" Grid.Column="0" Target="{Binding ElementName=txtEmail}">Email:</Label>
<TextBox Grid.Row="2" Grid.Column="1" x:Name="txtEmail" Text="{Binding Email, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="3" Grid.Column="0" Target="{Binding ElementName=txtPassword}">Password:</Label>
<TextBox Grid.Row="3" Grid.Column="1" x:Name="txtPassword" Text="{Binding Password, UpdateSourceTrigger=PropertyChanged}"/>
<Label Grid.Row="4" Grid.Column="0" Target="{Binding ElementName=txtPasswordConfirmation}">Confirm Password:</Label>
<TextBox Grid.Row="4" Grid.Column="1" x:Name="txtPasswordConfirmation" Text="{Binding PasswordConfirmation, UpdateSourceTrigger=PropertyChanged}"/>
<Button Grid.Row="5" Grid.Column="0" Command="{s:Action SubmitAlways}" HorizontalAlignment="Left">Submit Always</Button>
<Button Grid.Row="5" Grid.Column="1" Command="{s:Action Submit}" HorizontalAlignment="Left">Submit</Button>
</Grid>
</UserControl>