Skip to content

Commit 66e77ab

Browse files
authored
Merge branch 'master' into fix-tilecontrol
2 parents 79a5b38 + 1d70e62 commit 66e77ab

File tree

14 files changed

+144
-78
lines changed

14 files changed

+144
-78
lines changed

Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@
617617
<Content Include="SamplePages\Animations\Behaviors\RotateBehaviorXaml.bind" />
618618
<Content Include="SamplePages\Animations\Effects\EffectAnimations.bind" />
619619
<Content Include="SamplePages\VisualEffectFactory\VisualEffectFactory.bind" />
620+
<Content Include="SamplePages\Animations\Activities\InvokeActionsActivityCode.bind" />
621+
<Content Include="SamplePages\Animations\Activities\StartAnimationActivityCode.bind" />
620622
</ItemGroup>
621623
<ItemGroup>
622624
<Compile Include="App.xaml.cs">
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.Toolkit.Uwp.UI.Animations;
2+
3+
// Fade out the TextBlock
4+
await AnimationBuilder
5+
.Create()
6+
.Opacity(from: 1, to: 0, duration: TimeSpan.FromSeconds(1), easingType: EasingType.Linear)
7+
.StartAsync(MyText);
8+
9+
// Change the text and the sound here...
10+
11+
// Fade the TextBlock back in
12+
await AnimationBuilder
13+
.Create()
14+
.Opacity(to: 1, duration: TimeSpan.FromSeconds(1), easingType: EasingType.Linear)
15+
.StartAsync(MyText);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Microsoft.Toolkit.Uwp.UI.Animations;
2+
3+
// Move the button down and then back up
4+
AnimationBuilder
5+
.Create()
6+
.Translation(Axis.Y).TimedKeyFrames(b => b
7+
.KeyFrame(TimeSpan.Zero, 0)
8+
.KeyFrame(TimeSpan.FromSeconds(3), 32, EasingType.Linear)
9+
.KeyFrame(TimeSpan.FromSeconds(9), 32, EasingType.Linear)
10+
.KeyFrame(TimeSpan.FromSeconds(12), 0, EasingType.Linear))
11+
.Start(MyButton);
12+
13+
// Fade the image out and then back in
14+
AnimationBuilder
15+
.Create()
16+
.Opacity().TimedKeyFrames(
17+
delay: TimeSpan.FromSeconds(3),
18+
build: b => b
19+
.KeyFrame(TimeSpan.Zero, 1)
20+
.KeyFrame(TimeSpan.FromSeconds(3), 0, EasingType.Linear)
21+
.KeyFrame(TimeSpan.FromSeconds(6), 1, EasingType.Linear))
22+
.Start(MyImage);
23+
24+
// Alternatively, a simpler but less efficient solution involves separate animations
25+
await AnimationBuilder
26+
.Create()
27+
.Translation(Axis.Y, to: 32, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
28+
.StartAsync(MyButton);
29+
await AnimationBuilder
30+
.Create()
31+
.Opacity(to: 0, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
32+
.StartAsync(MyImage);
33+
await AnimationBuilder
34+
.Create()
35+
.Opacity(to: 1, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
36+
.StartAsync(MyImage);
37+
await AnimationBuilder
38+
.Create()
39+
.Translation(Axis.Y, to: 0, duration: TimeSpan.FromSeconds(3), easingType: EasingType.Linear)
40+
.StartAsync(MyButton);

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMask.bind

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,34 @@
3333
</Grid.RowDefinitions>
3434

3535
<TextBox Name="AlphaTextBox"
36-
ui:TextBoxMask.Mask="9a9a-a9a*"
36+
ui:TextBoxExtensions.Mask="9a9a-a9a*"
3737
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)"
3838
HeaderTemplate="{StaticResource HeaderTemplate}"
3939
Style="{StaticResource MaskedTextBoxStyle}"
40-
Text="TextBoxMask" />
40+
Text="TextBoxMask" />
4141

4242
<TextBox Grid.Row="1"
43-
ui:TextBoxMask.Mask="+1999-9999"
44-
ui:TextBoxMask.PlaceHolder=" "
43+
ui:TextBoxExtensions.Mask="+1999-9999"
44+
ui:TextBoxExtensions.MaskPlaceholder=" "
4545
Header="Text box with Mask +1999-9999 and placeHolder as space (placeholder represents the characters the user can change on runtime)"
4646
HeaderTemplate="{StaticResource HeaderTemplate}"
4747
Style="{StaticResource MaskedTextBoxStyle}" />
4848

4949
<TextBox Grid.Row="2"
50-
ui:TextBoxMask.Mask="+\964 799 999 9999"
50+
ui:TextBoxExtensions.Mask="+\964 799 999 9999"
5151
Header="Text box with Mask +964 799 999 9999 (Notice how we escape the first 9 with a backslash)"
5252
HeaderTemplate="{StaticResource HeaderTemplate}"
5353
Style="{StaticResource MaskedTextBoxStyle}" />
5454

5555
<TextBox Grid.Row="3"
56-
ui:TextBoxMask.Mask="99\\99\\9999"
56+
ui:TextBoxExtensions.Mask="99\\99\\9999"
5757
Header="Text box with Mask 99\99\9999 (You can escape a backslash with another backslash)"
5858
HeaderTemplate="{StaticResource HeaderTemplate}"
5959
Style="{StaticResource MaskedTextBoxStyle}" />
6060

6161
<TextBox Grid.Row="4"
62-
ui:TextBoxMask.CustomMask="5:[1-5],c:[a-c]"
63-
ui:TextBoxMask.Mask="a5c-5c*9"
62+
ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
63+
ui:TextBoxExtensions.Mask="a5c-5c*9"
6464
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]"
6565
HeaderTemplate="{StaticResource HeaderTemplate}"
6666
Style="{StaticResource MaskedTextBoxStyle}" />

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxMask/TextBoxMaskPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<TextBox ui:TextBoxExtensions.Mask="9a9a--a9a*"/>
1212

1313
<TextBox ui:TextBoxExtensions.Mask="+1999-9999"
14-
ui:TextBoxExtensions.PlaceHolder=" " />
14+
ui:TextBoxExtensions.MaskPlaceholder=" " />
1515

1616
<TextBox ui:TextBoxExtensions.Mask="+\964 799 999 9999"
17-
ui:TextBoxExtensions.PlaceHolder=" " />
17+
ui:TextBoxExtensions.MaskPlaceholder=" " />
1818

1919
<TextBox ui:TextBoxExtensions.CustomMask="5:[1-5],c:[a-c]"
2020
ui:TextBoxExtensions.Mask="a5c-5c*9" />

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextBoxRegex/TextBoxRegex.bind

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,70 +34,70 @@
3434

3535
<StackPanel Margin="10,10,10,0">
3636
<TextBox Name="PhoneNumberValidator"
37-
ui:TextBoxRegex.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
37+
ui:TextBoxExtensions.Regex="^\s*\+?\s*([0-9][\s-]*){9,}$"
3838
Header="Text box with Regex extension for phone number, validation occurs on TextChanged"
3939
HeaderTemplate="{StaticResource HeaderTemplate}"
4040
Style="{StaticResource TextBoxRegexStyle}" />
4141
<StackPanel Orientation="Horizontal">
4242
<TextBlock Text="Is Valid: " />
43-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
43+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=PhoneNumberValidator, Converter={StaticResource StringFormatConverter}}" />
4444
</StackPanel>
4545

4646
</StackPanel>
4747

4848
<StackPanel Grid.Row="1"
49-
Margin="10,10,10,0">
49+
Margin="10,10,10,0">
5050
<TextBox Name="CharactValidator"
51-
ui:TextBoxRegex.ValidationMode="Dynamic"
52-
ui:TextBoxRegex.ValidationType="Characters"
51+
ui:TextBoxExtensions.ValidationMode="Dynamic"
52+
ui:TextBoxExtensions.ValidationType="Characters"
5353
Header="Text box with ValidationType=Characters, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
5454
HeaderTemplate="{StaticResource HeaderTemplate}"
5555
Style="{StaticResource TextBoxRegexStyle}"
5656
Text="abcdef" />
5757
<StackPanel Orientation="Horizontal">
5858
<TextBlock Text="Is Valid: " />
59-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
59+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=CharactValidator, Converter={StaticResource StringFormatConverter}}" />
6060
</StackPanel>
6161
</StackPanel>
6262

6363
<StackPanel Grid.Row="2"
64-
Margin="10,10,10,0">
64+
Margin="10,10,10,0">
6565
<TextBox Name="EmailValidator"
66-
ui:TextBoxRegex.ValidationType="Email"
66+
ui:TextBoxExtensions.ValidationType="Email"
6767
Header="Text box with ValidationType=Email, validation occurs on TextChanged"
6868
HeaderTemplate="{StaticResource HeaderTemplate}"
6969
Style="{StaticResource TextBoxRegexStyle}" />
7070
<StackPanel Orientation="Horizontal">
7171
<TextBlock Text="Is Valid: " />
72-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
72+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=EmailValidator, Converter={StaticResource StringFormatConverter}}" />
7373
</StackPanel>
7474
</StackPanel>
7575

7676
<StackPanel Grid.Row="3"
7777
Margin="10,10,10,0">
7878
<TextBox Name="DecimalValidatorForce"
79-
ui:TextBoxRegex.ValidationMode="Forced"
80-
ui:TextBoxRegex.ValidationType="Decimal"
79+
ui:TextBoxExtensions.ValidationMode="Forced"
80+
ui:TextBoxExtensions.ValidationType="Decimal"
8181
Header="Text box with ValidationType=Decimal, validation occurs on TextChanged and force occurs on lose focus with ValidationMode=Force (333,111 or 333.111)"
8282
HeaderTemplate="{StaticResource HeaderTemplate}"
8383
Style="{StaticResource TextBoxRegexStyle}" />
8484
<StackPanel Orientation="Horizontal">
8585
<TextBlock Text="Is Valid: " />
86-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
86+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=DecimalValidatorForce, Converter={StaticResource StringFormatConverter}}" />
8787
</StackPanel>
8888
</StackPanel>
8989

9090
<StackPanel Grid.Row="4"
9191
Margin="10,10,10,0">
9292
<TextBox Name="NumberValidatorDynamic"
93-
ui:TextBoxRegex.ValidationMode="Dynamic"
94-
ui:TextBoxRegex.ValidationType="Number"
93+
ui:TextBoxExtensions.ValidationMode="Dynamic"
94+
ui:TextBoxExtensions.ValidationType="Number"
9595
Header="Text box with ValidationType=Number, validation occurs at input with ValidationMode=Dynamic and clear only single character when value is invalid"
9696
HeaderTemplate="{StaticResource HeaderTemplate}"
9797
Style="{StaticResource TextBoxRegexStyle}" />
9898
<StackPanel Orientation="Horizontal">
9999
<TextBlock Text="Is Valid: " />
100-
<TextBlock Text="{Binding (ui:TextBoxRegex.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
100+
<TextBlock Text="{Binding (ui:TextBoxExtensions.IsValid), ElementName=NumberValidatorDynamic, Converter={StaticResource StringFormatConverter}}" />
101101
</StackPanel>
102102
</StackPanel>
103103

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,15 @@
485485
"About": "Activity for Animations to Start another Animation",
486486
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations/Xaml/Activities",
487487
"XamlCodeFile": "/SamplePages/Animations/Activities/StartAnimationActivity.bind",
488+
"CodeFile": "/SamplePages/Animations/Activities/StartAnimationActivityCode.bind",
488489
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Fade.md"
489490
},
490491
{
491492
"Name": "InvokeActionsActivity",
492493
"Subcategory": "Activities",
493494
"About": "Activity chaining Actions from the Behaviors package into an Animation schedule.",
494495
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Behaviors/Animations",
496+
"CodeFile": "/SamplePages/Animations/Activities/InvokeActionsActivityCode.bind",
495497
"XamlCodeFile": "/SamplePages/Animations/Activities/InvokeActionsActivity.bind",
496498
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/animations/Fade.md"
497499
},

Microsoft.Toolkit.Uwp.UI.Animations/Extensions/StoryboardAnimations.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ public static Task BeginAsync(this Storyboard storyboard)
2323
{
2424
TaskCompletionSource<object?> taskCompletionSource = new TaskCompletionSource<object?>();
2525

26-
storyboard.Completed += (_, _) => taskCompletionSource.SetResult(null);
26+
void OnCompleted(object sender, object e)
27+
{
28+
((Storyboard)sender).Completed -= OnCompleted;
29+
30+
taskCompletionSource.SetResult(null);
31+
}
32+
33+
storyboard.Completed += OnCompleted;
2734

2835
storyboard.Begin();
2936

Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/SurfaceDialOptions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Windows.UI.Input;
66
using Windows.UI.Xaml;
77
using Windows.UI.Xaml.Controls;
8-
using Windows.UI.Xaml.Input;
98

109
namespace Microsoft.Toolkit.Uwp.UI
1110
{

Microsoft.Toolkit.Uwp.UI/Extensions/TextBox/TextBoxExtensions.Mask.Internals.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static void Textbox_Loaded(object sender, RoutedEventArgs e)
4949
return;
5050
}
5151

52-
var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string;
52+
var placeHolderValue = textbox.GetValue(MaskPlaceholderProperty) as string;
5353
if (string.IsNullOrEmpty(placeHolderValue))
5454
{
5555
throw new ArgumentException("PlaceHolder can't be null or empty");
@@ -152,7 +152,7 @@ private static void Textbox_GotFocus_Mask(object sender, RoutedEventArgs e)
152152
{
153153
var textbox = (TextBox)sender;
154154
var mask = textbox?.GetValue(MaskProperty) as string;
155-
var placeHolderValue = textbox?.GetValue(PlaceHolderProperty) as string;
155+
var placeHolderValue = textbox?.GetValue(MaskPlaceholderProperty) as string;
156156
var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;
157157
if (string.IsNullOrWhiteSpace(mask) ||
158158
representationDictionary == null ||
@@ -194,7 +194,7 @@ private static async void Textbox_Paste(object sender, TextControlPasteEventArgs
194194
var textbox = (TextBox)sender;
195195
var mask = textbox.GetValue(MaskProperty) as string;
196196
var representationDictionary = textbox?.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;
197-
var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string;
197+
var placeHolderValue = textbox.GetValue(MaskPlaceholderProperty) as string;
198198
if (string.IsNullOrWhiteSpace(mask) ||
199199
representationDictionary == null ||
200200
string.IsNullOrEmpty(placeHolderValue))
@@ -262,7 +262,7 @@ private static void Textbox_TextChanging(TextBox textbox, TextBoxTextChangingEve
262262
var escapedChars = textbox.GetValue(EscapedCharacterIndicesProperty) as List<int>;
263263

264264
var representationDictionary = textbox.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;
265-
var placeHolderValue = textbox?.GetValue(PlaceHolderProperty) as string;
265+
var placeHolderValue = textbox?.GetValue(MaskPlaceholderProperty) as string;
266266
var oldText = textbox.GetValue(OldTextProperty) as string;
267267
var oldSelectionStart = (int)textbox.GetValue(OldSelectionStartProperty);
268268
var oldSelectionLength = (int)textbox.GetValue(OldSelectionLengthProperty);

0 commit comments

Comments
 (0)