Skip to content

Commit

Permalink
Implemented validation sample using ValidationControl with error styling
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Aug 21, 2021
1 parent 7a9dfc3 commit ee72f4d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Samples/Samples.Shared/ValidationPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d xamarin">

<!-- <Page.Resources>
<Page.Resources>
<!--
<Style x:Key="textBoxInError" TargetType="Control">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
Expand All @@ -35,7 +36,15 @@
</Setter.Value>
</Setter>
</Style>
</Page.Resources>-->
-->
<Style x:Key="TextBoxErrorStyle" TargetType="TextBox">
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
</Style>
<DataTemplate x:Key="ErrorItemTemplate">
<TextBlock Foreground="Red" Text="{Binding}" />
</DataTemplate>
</Page.Resources>
<Grid
MinWidth="300"
Margin="0,25,0,0"
Expand All @@ -62,7 +71,9 @@
Grid.Row="0"
Grid.Column="1"
Margin="5"
PropertyName="Value">
PropertyName="Value"
ErrorContentStyle="{StaticResource TextBoxErrorStyle}"
ErrorItemTemplate="{StaticResource ErrorItemTemplate}">
<TextBox Description="Valid value is 42" Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</ctrl:ValidationControl>
<TextBlock
Expand All @@ -77,7 +88,9 @@
Grid.Row="1"
Grid.Column="1"
Margin="5"
PropertyName="Password">
PropertyName="Password"
ErrorContentStyle="{StaticResource TextBoxErrorStyle}"
ErrorItemTemplate="{StaticResource ErrorItemTemplate}">
<TextBox Description="Requires upper case, lower case and digit" Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</ctrl:ValidationControl>

Expand Down

0 comments on commit ee72f4d

Please sign in to comment.