Skip to content

Commit 56c9f47

Browse files
committed
Updated InputValidator samples
1 parent 23229e9 commit 56c9f47

6 files changed

Lines changed: 117 additions & 27 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public ValidatorCollection InputDateValidators { get; } = new ValidatorCollection { new RequiredValidator(), new BetweenValidator(DateTimeOffset.Now.AddDays(-7), DateTimeOffset.Now.AddDays(7)) };
2+
3+
public DateTimeOffset? InputDate
4+
{
5+
get => inputDate;
6+
set => this.SetProperty(ref inputDate, value);
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Page
2+
x:Class="MADE.Samples.Features.Samples.Pages.InputValidatorPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:made="using:MADE.UI.Controls"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
9+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
10+
mc:Ignorable="d">
11+
12+
<Grid>
13+
<made:InputValidator
14+
x:Name="DatePickerValidator"
15+
Input="{Binding SelectedDate, Mode=TwoWay, ElementName=DatePicker, UpdateSourceTrigger=PropertyChanged}"
16+
Validators="{x:Bind InputDateValidators}">
17+
<DatePicker
18+
x:Name="DatePicker"
19+
Header="DatePicker with InputValidator"
20+
SelectedDate="{x:Bind InputDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
21+
</made:InputValidator>
22+
</Grid>
23+
</Page>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public ValidatorCollection InputTextValidators { get; } = new ValidatorCollection { new RequiredValidator(), new MaxLengthValidator(16) };
2+
3+
public string InputText
4+
{
5+
get => inputText;
6+
set => this.SetProperty(ref inputText, value);
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Page
2+
x:Class="MADE.Samples.Features.Samples.Pages.InputValidatorPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:made="using:MADE.UI.Controls"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
9+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
10+
mc:Ignorable="d">
11+
12+
<Grid>
13+
<made:InputValidator
14+
x:Name="TextBoxValidator"
15+
Input="{x:Bind TextBox.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
16+
Validators="{x:Bind InputTextValidators}">
17+
<TextBox
18+
x:Name="TextBox"
19+
Header="TextBox with InputValidator"
20+
Text="{x:Bind InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
21+
</made:InputValidator>
22+
</Grid>
23+
</Page>

samples/MADE.Samples/MADE.Samples.Shared/Features/Samples/Pages/InputValidatorPage.xaml

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
x:Class="MADE.Samples.Features.Samples.Pages.InputValidatorPage"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:controls="using:MADE.UI.Controls"
65
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:made="using:MADE.UI.Controls"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
xmlns:pages="using:MADE.UI.Views.Navigation.Pages"
9+
xmlns:samples="using:MADE.Samples.Infrastructure.Controls"
910
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1011
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
1112
mc:Ignorable="d">
@@ -28,15 +29,15 @@
2829
</win:CommandBar.Content>
2930
</win:CommandBar>
3031

31-
<Grid Grid.Row="1" Padding="12">
32+
<Grid Grid.Row="1" Padding="16">
3233
<Grid.RowDefinitions>
3334
<RowDefinition Height="Auto" />
3435
<RowDefinition Height="Auto" />
3536
<RowDefinition Height="*" />
3637
</Grid.RowDefinitions>
3738

3839
<TextBlock
39-
Margin="0,0,0,12"
40+
Margin="0,0,0,16"
4041
Style="{StaticResource TitleTextBlockStyle}"
4142
Text="InputValidator control" />
4243

@@ -54,33 +55,43 @@
5455
<RowDefinition Height="*" />
5556
</Grid.RowDefinitions>
5657

57-
<controls:InputValidator
58-
x:Name="TextBoxValidator"
59-
Margin="0,0,0,12"
60-
Input="{x:Bind TextBox.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
61-
Validators="{x:Bind ViewModel.InputTextValidators}">
62-
<TextBox
63-
x:Name="TextBox"
64-
Header="TextBox with InputValidator"
65-
Text="{x:Bind ViewModel.InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
66-
</controls:InputValidator>
58+
<samples:SampleControl
59+
Margin="0,0,0,32"
60+
CodeSource="InputValidator/InputValidatorTextBoxCode.txt"
61+
SampleName="A TextBox wrapped with the InputValidator with a required value and max character length of 16"
62+
XamlSource="InputValidator/InputValidatorTextBoxXaml.txt">
63+
<samples:SampleControl.Sample>
64+
<made:InputValidator
65+
x:Name="TextBoxValidator"
66+
Input="{x:Bind TextBox.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
67+
Validators="{x:Bind ViewModel.InputTextValidators}">
68+
<TextBox
69+
x:Name="TextBox"
70+
Header="TextBox with InputValidator"
71+
Text="{x:Bind ViewModel.InputText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
72+
</made:InputValidator>
73+
</samples:SampleControl.Sample>
74+
</samples:SampleControl>
6775

68-
<controls:InputValidator
69-
x:Name="DatePickerValidator"
76+
<samples:SampleControl
7077
Grid.Row="1"
71-
Margin="0,0,0,12"
72-
Input="{Binding SelectedDate, Mode=TwoWay, ElementName=DatePicker, UpdateSourceTrigger=PropertyChanged}"
73-
Validators="{x:Bind ViewModel.InputDateValidators}">
74-
<DatePicker
75-
x:Name="DatePicker"
76-
Header="DatePicker with InputValidator"
77-
SelectedDate="{x:Bind ViewModel.InputDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
78-
</controls:InputValidator>
78+
CodeSource="InputValidator/InputValidatorDatePickerCode.txt"
79+
SampleName="A DatePicker wrapped with the InputValidator with a required value and date between the last 7 days and the next 7 days"
80+
XamlSource="InputValidator/InputValidatorDatePickerXaml.txt">
81+
<samples:SampleControl.Sample>
82+
<made:InputValidator
83+
x:Name="DatePickerValidator"
84+
Input="{Binding SelectedDate, Mode=TwoWay, ElementName=DatePicker, UpdateSourceTrigger=PropertyChanged}"
85+
Validators="{x:Bind ViewModel.InputDateValidators}">
86+
<DatePicker
87+
x:Name="DatePicker"
88+
Header="DatePicker with InputValidator"
89+
SelectedDate="{x:Bind ViewModel.InputDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
90+
</made:InputValidator>
91+
</samples:SampleControl.Sample>
92+
</samples:SampleControl>
7993
</Grid>
8094
</ScrollViewer>
81-
8295
</Grid>
83-
84-
8596
</Grid>
8697
</pages:MvvmPage>

samples/MADE.Samples/MADE.Samples.Shared/MADE.Samples.Shared.projitems

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@
5454
<Generator>
5555
</Generator>
5656
</Content>
57+
<Content Include="$(MSBuildThisFileDirectory)Features\Samples\Assets\InputValidator\InputValidatorDatePickerCode.txt">
58+
<SubType>Designer</SubType>
59+
<Generator>
60+
</Generator>
61+
</Content>
62+
<Content Include="$(MSBuildThisFileDirectory)Features\Samples\Assets\InputValidator\InputValidatorTextBoxCode.txt">
63+
<SubType>Designer</SubType>
64+
<Generator>
65+
</Generator>
66+
</Content>
67+
<Content Include="$(MSBuildThisFileDirectory)Features\Samples\Assets\InputValidator\InputValidatorDatePickerXaml.txt">
68+
<SubType>Designer</SubType>
69+
<Generator>
70+
</Generator>
71+
</Content>
72+
<Content Include="$(MSBuildThisFileDirectory)Features\Samples\Assets\InputValidator\InputValidatorTextBoxXaml.txt">
73+
<SubType>Designer</SubType>
74+
<Generator>
75+
</Generator>
76+
</Content>
5777
<Page Include="$(MSBuildThisFileDirectory)Features\Home\Pages\MainPage.xaml">
5878
<SubType>Designer</SubType>
5979
<Generator>MSBuild:Compile</Generator>
@@ -85,7 +105,6 @@
85105
</ItemGroup>
86106
<ItemGroup>
87107
<Folder Include="$(MSBuildThisFileDirectory)Features\Home\Pages\" />
88-
<Folder Include="$(MSBuildThisFileDirectory)Features\Samples\Assets\InputValidator\" />
89108
<Folder Include="$(MSBuildThisFileDirectory)Infrastructure\Validation\" />
90109
</ItemGroup>
91110
<ItemGroup>

0 commit comments

Comments
 (0)