-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improving Staggered samples * Other minor sample tweaks * Adding icon and tweaking staggered md * Adding TextBoxExtension samples * XAML styling
- Loading branch information
Showing
20 changed files
with
377 additions
and
156 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
104 changes: 104 additions & 0 deletions
104
components/Extensions/samples/TextBoxExtensions/RegexSample.xaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<Page x:Class="ExtensionsExperiment.Samples.TextBoxExtensions.RegexSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:converters="using:CommunityToolkit.Converters" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="using:CommunityToolkit.WinUI" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<Style x:Key="TextBoxRegexStyle" | ||
TargetType="TextBox"> | ||
<Setter Property="VerticalAlignment" Value="Top" /> | ||
<Setter Property="TextWrapping" Value="Wrap" /> | ||
</Style> | ||
<DataTemplate x:Key="HeaderTemplate"> | ||
<StackPanel> | ||
<TextBlock Text="{Binding}" | ||
TextWrapping="WrapWholeWords" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</Page.Resources> | ||
|
||
<Grid> | ||
<Grid RowSpacing="32"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
<StackPanel> | ||
<TextBox Name="PhoneNumberValidator" | ||
ui:TextBoxExtensions.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$" | ||
Header="Text box with Regex extension for phone number, validation occurs on TextChanged" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource TextBoxRegexStyle}" /> | ||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}"> | ||
<Run Text="Is valid: " /> | ||
<Run FontWeight="SemiBold" | ||
Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=PhoneNumberValidator}" /> | ||
</TextBlock> | ||
</StackPanel> | ||
|
||
<StackPanel Grid.Row="1"> | ||
<TextBox Name="CharactValidator" | ||
ui:TextBoxExtensions.ValidationMode="Dynamic" | ||
ui:TextBoxExtensions.ValidationType="Characters" | ||
Header="Text box with ValidationType=Characters, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource TextBoxRegexStyle}" | ||
Text="abcdef" /> | ||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}"> | ||
<Run Text="Is valid: " /> | ||
<Run FontWeight="SemiBold" | ||
Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=CharactValidator}" /> | ||
</TextBlock> | ||
</StackPanel> | ||
|
||
<StackPanel Grid.Row="2"> | ||
<TextBox Name="EmailValidator" | ||
ui:TextBoxExtensions.ValidationType="Email" | ||
Header="Text box with ValidationType=Email, validation occurs on TextChanged" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource TextBoxRegexStyle}" /> | ||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}"> | ||
<Run Text="Is valid: " /> | ||
<Run FontWeight="SemiBold" | ||
Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=EmailValidator}" /> | ||
</TextBlock> | ||
</StackPanel> | ||
|
||
<StackPanel Grid.Row="3"> | ||
<TextBox Name="DecimalValidatorForce" | ||
ui:TextBoxExtensions.ValidationMode="Forced" | ||
ui:TextBoxExtensions.ValidationType="Decimal" | ||
Header="Text box with ValidationType=Decimal, validation occurs on TextChanged and force occurs on lose focus with ValidationMode=Force (333,111 or 333.111)" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource TextBoxRegexStyle}" /> | ||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}"> | ||
<Run Text="Is valid: " /> | ||
<Run FontWeight="SemiBold" | ||
Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=DecimalValidatorForce}" /> | ||
</TextBlock> | ||
</StackPanel> | ||
|
||
<StackPanel Grid.Row="4"> | ||
<TextBox Name="NumberValidatorDynamic" | ||
ui:TextBoxExtensions.ValidationMode="Dynamic" | ||
ui:TextBoxExtensions.ValidationType="Number" | ||
Header="Text box with ValidationType=Number, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource TextBoxRegexStyle}" /> | ||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}"> | ||
<Run Text="Is valid: " /> | ||
<Run FontWeight="SemiBold" | ||
Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=NumberValidatorDynamic}" /> | ||
</TextBlock> | ||
</StackPanel> | ||
</Grid> | ||
</Grid> | ||
</Page> |
14 changes: 14 additions & 0 deletions
14
components/Extensions/samples/TextBoxExtensions/RegexSample.xaml.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace ExtensionsExperiment.Samples.TextBoxExtensions; | ||
|
||
[ToolkitSample(id: nameof(RegexSample), "Regex Extension", description: "A sample for showing how to use the Regex Extension.")] | ||
public sealed partial class RegexSample : Page | ||
{ | ||
public RegexSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
components/Extensions/samples/TextBoxExtensions/SurfaceDialOptionsSample.xaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Page x:Class="ExtensionsExperiment.Samples.TextBoxExtensions.SurfaceDialOptionsSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="using:CommunityToolkit.WinUI" | ||
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
mc:Ignorable="d"> | ||
|
||
|
||
<win:TextBox HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Header="For this sample, you need a Surface Dial" | ||
Text="0"> | ||
<ui:TextBoxExtensions.SurfaceDialOptions> | ||
<ui:SurfaceDialOptions EnableHapticFeedback="True" | ||
EnableMinMaxValue="True" | ||
EnableTapToNextControl="False" | ||
Icon="Ruler" | ||
MaxValue="100" | ||
MinValue="0" | ||
RotationResolutionInDegrees="12" | ||
StepValue="1" /> | ||
</ui:TextBoxExtensions.SurfaceDialOptions> | ||
</win:TextBox> | ||
</Page> |
14 changes: 14 additions & 0 deletions
14
components/Extensions/samples/TextBoxExtensions/SurfaceDialOptionsSample.xaml.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace ExtensionsExperiment.Samples.TextBoxExtensions; | ||
|
||
[ToolkitSample(id: nameof(SurfaceDialOptionsSample), "SurfaceDialOptions Extension", description: "A sample for showing how to use the SurfaceDialOptions Extension.")] | ||
public sealed partial class SurfaceDialOptionsSample : Page | ||
{ | ||
public SurfaceDialOptionsSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
components/Extensions/samples/TextBoxExtensions/TextBoxMaskSample.xaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<Page x:Class="ExtensionsExperiment.Samples.TextBoxExtensions.TextBoxMaskSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="using:CommunityToolkit.WinUI" | ||
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
mc:Ignorable="d"> | ||
|
||
|
||
<Page.Resources> | ||
<Style x:Key="MaskedTextBoxStyle" | ||
TargetType="TextBox"> | ||
<Setter Property="VerticalAlignment" Value="Top" /> | ||
<Setter Property="TextWrapping" Value="Wrap" /> | ||
</Style> | ||
<DataTemplate x:Key="HeaderTemplate"> | ||
<StackPanel> | ||
<TextBlock Text="{Binding}" | ||
TextWrapping="WrapWholeWords" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</Page.Resources> | ||
|
||
<Grid> | ||
<StackPanel Spacing="24"> | ||
<TextBox ui:TextBoxExtensions.Mask="9a9a-a9a*" | ||
Header="Text box with Mask 9a9a-a9a* (9 allows from 0 to 9, a allow from a to Z and * allows both a and 9)" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource MaskedTextBoxStyle}" | ||
Text="TextBoxMask" /> | ||
|
||
<TextBox ui:TextBoxExtensions.Mask="+1999-9999" | ||
ui:TextBoxExtensions.MaskPlaceholder=" " | ||
Header="Text box with Mask +1999-9999 and placeHolder as space (placeholder represents the characters the user can change on runtime)" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource MaskedTextBoxStyle}" /> | ||
|
||
<TextBox ui:TextBoxExtensions.Mask="+\964 799 999 9999" | ||
Header="Text box with Mask +964 799 999 9999 (Notice how we escape the first 9 with a backslash)" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource MaskedTextBoxStyle}" /> | ||
|
||
<TextBox ui:TextBoxExtensions.Mask="99\\99\\9999" | ||
Header="Text box with Mask 99\99\9999 (You can escape a backslash with another backslash)" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource MaskedTextBoxStyle}" /> | ||
|
||
<TextBox ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]" | ||
ui:TextBoxExtensions.Mask="a5c-5c*9" | ||
Header="Text box with CustomMask in case you want to define your own variable character like a, 9 and *. Mask: a5c-5c*9, 5: [1-5], c: [a-c]" | ||
HeaderTemplate="{StaticResource HeaderTemplate}" | ||
Style="{StaticResource MaskedTextBoxStyle}" /> | ||
|
||
</StackPanel> | ||
</Grid> | ||
</Page> |
Oops, something went wrong.