This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 457
Add VSM to ValidationBehavior #955
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f743c40
Add VSM to ValidationBehavior
Cfun1 8c89827
dumb commit: Re trigger CI
Cfun1 26ccb1e
Fix typo
Cfun1 3e9c83e
Merge branch 'validation-vsm' of https://github.com/Cfun1/XamarinComm…
Cfun1 d50c1fc
Fix typo
Cfun1 ea5188a
Change string properties to public
Cfun1 76781c0
Apply Pascal Case Naming
Cfun1 6431357
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Valida…
AndreiMisiukevich 8a8025b
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Valida…
AndreiMisiukevich e3e7fc6
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Valida…
AndreiMisiukevich 4d55475
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Valida…
AndreiMisiukevich df74370
Update src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Valida…
AndreiMisiukevich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
92 changes: 57 additions & 35 deletions
92
samples/XCT.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<pages:BasePage xmlns="http://xamarin.com/schemas/2014/forms" | ||
<pages:BasePage x:Name="Page" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Behaviors.CharactersValidationBehaviorPage" | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:xct="http://xamarin.com/schemas/2020/toolkit" | ||
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages" | ||
x:Name="Page" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Behaviors.CharactersValidationBehaviorPage"> | ||
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"> | ||
|
||
<pages:BasePage.Resources> | ||
<Style x:Key="InvalidEntryStyle" | ||
TargetType="Entry"> | ||
<Setter Property="TextColor" | ||
Value="Red" /> | ||
<Setter Property="TextColor" Value="Red"/> | ||
</Style> | ||
|
||
<Style x:Key="ValidEntryStyle" | ||
TargetType="Entry"> | ||
<Setter Property="TextColor" Value="Green"/> | ||
</Style> | ||
</pages:BasePage.Resources> | ||
|
||
<StackLayout Padding="{StaticResource ContentPadding}" | ||
Spacing="25" | ||
VerticalOptions="StartAndExpand"> | ||
<Label Text="Text color will change accordingly to the style that is configured when an invalid string is entered." /> | ||
<Label Text="Text color will change accordingly to the style that is configured when an invalid string is entered."/> | ||
<Frame Margin="{StaticResource ContentPadding}" | ||
CornerRadius="10"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Label Text="CharacterType" /> | ||
<Picker x:Name="CharacterTypePicker" | ||
<Label Text="CharacterType"/> | ||
<Picker x:Name="CharacterTypePicker" Grid.Column="1" | ||
Title="CharacterType" | ||
Grid.Column="1" | ||
ItemsSource="{Binding CharacterTypes, | ||
Source={x:Reference Page}}" | ||
SelectedIndex="1" /> | ||
ItemsSource="{Binding CharacterTypes, Source={x:Reference Page}}" | ||
SelectedIndex="1"/> | ||
<Label Grid.Row="1" | ||
Text="MinimumCharacterCountEntry" /> | ||
<Entry x:Name="MinimumCharacterCountEntry" | ||
Grid.Row="1" | ||
Grid.Column="1" | ||
Text="MinimumCharacterCountEntry"/> | ||
<Entry x:Name="MinimumCharacterCountEntry" Grid.Row="1" Grid.Column="1" | ||
Keyboard="Numeric" | ||
Text="2" /> | ||
Text="2"/> | ||
<Label Grid.Row="2" | ||
Text="MaximumCharacterCountEntry" /> | ||
<Entry x:Name="MaximumCharacterCountEntry" | ||
Grid.Row="2" | ||
Grid.Column="1" | ||
Text="MaximumCharacterCountEntry"/> | ||
<Entry x:Name="MaximumCharacterCountEntry" Grid.Row="2" Grid.Column="1" | ||
Keyboard="Numeric" | ||
Text="20" /> | ||
Text="20"/> | ||
</Grid> | ||
</Frame> | ||
<Label Text="Type characters for validation behavior according to the settings you set upon." /> | ||
<Label Text="Type characters for validation behavior according to the settings you set upon."/> | ||
<Entry Placeholder="Type characters..."> | ||
<Entry.Behaviors> | ||
<xct:CharactersValidationBehavior CharacterType="{Binding SelectedItem, | ||
Source={x:Reference CharacterTypePicker}}" | ||
<xct:CharactersValidationBehavior CharacterType="{Binding SelectedItem, Source={x:Reference CharacterTypePicker}}" | ||
InvalidStyle="{StaticResource InvalidEntryStyle}" | ||
MaximumCharacterCount="{Binding Text, | ||
Source={x:Reference MaximumCharacterCountEntry}}" | ||
MinimumCharacterCount="{Binding Text, | ||
Source={x:Reference MinimumCharacterCountEntry}}" /> | ||
ValidStyle="{StaticResource ValidEntryStyle}" | ||
MaximumCharacterCount="{Binding Text, Source={x:Reference MaximumCharacterCountEntry}}" | ||
MinimumCharacterCount="{Binding Text, Source={x:Reference MinimumCharacterCountEntry}}"/> | ||
</Entry.Behaviors> | ||
</Entry> | ||
|
||
<Label Text="The same but styling handled by visual state manager."/> | ||
<Entry Placeholder="Type characters..."> | ||
<Entry.Behaviors> | ||
<xct:CharactersValidationBehavior Flags="ValidateOnValueChanging" | ||
CharacterType="{Binding SelectedItem, Source={x:Reference CharacterTypePicker}}" | ||
MaximumCharacterCount="{Binding Text, Source={x:Reference MaximumCharacterCountEntry}}" | ||
MinimumCharacterCount="{Binding Text, Source={x:Reference MinimumCharacterCountEntry}}"/> | ||
</Entry.Behaviors> | ||
|
||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Valid"> | ||
<VisualState.Setters> | ||
<Setter Property="TextColor" Value="Green"/> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Invalid"> | ||
<VisualState.Setters> | ||
<Setter Property="TextColor" Value="IndianRed"/> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
</Entry> | ||
|
||
</StackLayout> | ||
</pages:BasePage> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.