Skip to content

Commit 6c5f8a2

Browse files
committed
Fixes post code review
1 parent f9541bf commit 6c5f8a2

File tree

6 files changed

+73
-110
lines changed

6 files changed

+73
-110
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,6 @@
503503
<Compile Include="SamplePages\FocusBehavior\FocusBehaviorPage.xaml.cs">
504504
<DependentUpon>FocusBehaviorPage.xaml</DependentUpon>
505505
</Compile>
506-
<Compile Include="SamplePages\KeyDownTriggerBehavior\KeyDownTriggerBehaviorPage.xaml.cs">
507-
<DependentUpon>KeyDownTriggerBehaviorPage.xaml</DependentUpon>
508-
</Compile>
509506
<Compile Include="SamplePages\MetadataControl\MetadataControlPage.xaml.cs">
510507
<DependentUpon>MetadataControlPage.xaml</DependentUpon>
511508
</Compile>
@@ -978,10 +975,6 @@
978975
<Content Include="SamplePages\MetadataControl\MetadataControlCode.bind">
979976
<SubType>Designer</SubType>
980977
</Content>
981-
<Page Include="SamplePages\KeyDownTriggerBehavior\KeyDownTriggerBehaviorPage.xaml">
982-
<Generator>MSBuild:Compile</Generator>
983-
<SubType>Designer</SubType>
984-
</Page>
985978
<Page Include="SamplePages\MetadataControl\MetadataControlPage.xaml">
986979
<SubType>Designer</SubType>
987980
<Generator>MSBuild:Compile</Generator>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/KeyDownTriggerBehavior/KeyDownTriggerBehaviorPage.xaml

Lines changed: 0 additions & 60 deletions
This file was deleted.

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/KeyDownTriggerBehavior/KeyDownTriggerBehaviorPage.xaml.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1+
<!--<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
34
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
45
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
56
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
@@ -21,38 +22,89 @@
2122
</TextBox>
2223

2324
<Button Background="Gray" Margin="0,40,0,0" Width="200" Height="200" HorizontalAlignment="Center" VerticalAlignment="Center">
24-
<Explicit.Animations>
25-
<AnimationSet x:Name="MoveAnimation" IsSequential="True">
26-
<TranslationAnimation Duration="0:0:3" To="0,32,0" From="0,0,0" />
27-
<StartAnimationActivity Delay="0:0:3" Animation="{Binding ElementName=FadeOutAnimation}" />
28-
<StartAnimationActivity Delay="0:0:3" Animation="{Binding ElementName=FadeInAnimation}" />
29-
<TranslationAnimation Duration="0:0:1" To="0,0,0" From="0,32,0" />
30-
</AnimationSet>
31-
</Explicit.Animations>
25+
<ani:Explicit.Animations>
26+
<ani:AnimationSet x:Name="MoveAnimation" IsSequential="True">
27+
<ani:TranslationAnimation Duration="0:0:3" To="0,32,0" From="0,0,0" />
28+
<ani:StartAnimationActivity Delay="0:0:3" Animation="{Binding ElementName=FadeOutAnimation}"/>
29+
<ani:StartAnimationActivity Delay="0:0:3" Animation="{Binding ElementName=FadeInAnimation}"/>
30+
<ani:TranslationAnimation Duration="0:0:1" To="0,0,0" From="0,32,0" />
31+
</ani:AnimationSet>
32+
</ani:Explicit.Animations>
3233

3334
<Image Source="ms-appx:///Assets/ToolkitLogo.png" Height="100" Width="100">
34-
<Explicit.Animations>
35-
<AnimationSet x:Name="FadeOutAnimation">
36-
<OpacityAnimation From="1"
35+
<ani:Explicit.Animations>
36+
<ani:AnimationSet x:Name="FadeOutAnimation">
37+
<ani:OpacityAnimation From="1"
3738
To="0"
3839
Duration="0:0:1"
3940
Delay="0"
4041
EasingType="Linear"
41-
EasingMode="EaseOut" />
42-
</AnimationSet>
43-
<AnimationSet x:Name="FadeInAnimation">
44-
<OpacityAnimation From="0"
42+
EasingMode="EaseOut"/>
43+
</ani:AnimationSet>
44+
<ani:AnimationSet x:Name="FadeInAnimation">
45+
<ani:OpacityAnimation From="0"
4546
To="1"
4647
Duration="0:0:1"
4748
Delay="0"
4849
EasingType="Linear"
49-
EasingMode="EaseOut" />
50-
</AnimationSet>
51-
</Explicit.Animations>
50+
EasingMode="EaseOut"/>
51+
</ani:AnimationSet>
52+
</ani:Explicit.Animations>
5253
</Image>
5354

5455
</Button>
5556

5657
</StackPanel>
5758

59+
</Page>-->
60+
61+
<Page
62+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
63+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
64+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
65+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
67+
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
68+
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
69+
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
70+
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
71+
mc:Ignorable="d">
72+
73+
<Button Background="Gray" Width="200" Height="200" HorizontalAlignment="Center" VerticalAlignment="Center">
74+
<ani:Explicit.Animations>
75+
<ani:AnimationSet x:Name="MoveAnimation" IsSequential="True">
76+
<ani:TranslationAnimation Duration="0:0:3" To="0,32,0" From="0,0,0" />
77+
<ani:StartAnimationActivity Delay="0:0:3" Animation="{Binding ElementName=FadeOutAnimation}"/>
78+
<ani:StartAnimationActivity Delay="0:0:3" Animation="{Binding ElementName=FadeInAnimation}"/>
79+
<ani:TranslationAnimation Duration="0:0:1" To="0,0,0" From="0,32,0" />
80+
</ani:AnimationSet>
81+
</ani:Explicit.Animations>
82+
83+
<Image Source="ms-appx:///Assets/ToolkitLogo.png" Height="100" Width="100">
84+
<ani:Explicit.Animations>
85+
<ani:AnimationSet x:Name="FadeOutAnimation">
86+
<ani:OpacityAnimation From="1"
87+
To="0"
88+
Duration="0:0:1"
89+
Delay="0"
90+
EasingType="Linear"
91+
EasingMode="EaseOut"/>
92+
</ani:AnimationSet>
93+
<ani:AnimationSet x:Name="FadeInAnimation">
94+
<ani:OpacityAnimation From="0"
95+
To="1"
96+
Duration="0:0:1"
97+
Delay="0"
98+
EasingType="Linear"
99+
EasingMode="EaseOut"/>
100+
</ani:AnimationSet>
101+
</ani:Explicit.Animations>
102+
</Image>
103+
104+
<interactivity:Interaction.Behaviors>
105+
<interactions:EventTriggerBehavior EventName="Click">
106+
<behaviors:StartAnimationAction Animation="{Binding ElementName=MoveAnimation}"/>
107+
</interactions:EventTriggerBehavior>
108+
</interactivity:Interaction.Behaviors>
109+
</Button>
58110
</Page>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<triggers:UserHandPreferenceStateTrigger x:Key="UserHandPreferenceStateTrigger" />
3333
<triggers:UserInteractionModeStateTrigger x:Key="UserInteractionModeStateTrigger" />
3434
<behaviors:StartAnimationAction x:Key="StartAnimationAction" />
35+
<behaviors:KeyDownTriggerBehavior x:Key="KeyDownTriggerBehavior" />
3536
<behaviors:AutoSelectBehavior x:Key="AutoSelectBehavior" />
3637
<controls:ColorPicker x:Key="ColorPicker" />
3738
<controls:ColorPickerButton x:Key="ColorPickerButton" />

Microsoft.Toolkit.Uwp.UI.Behaviors/Keyboard/KeyDownTriggerBehavior.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Windows.Input;
21
using Microsoft.Xaml.Interactivity;
32
using Windows.System;
43
using Windows.UI.Xaml;
@@ -10,7 +9,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
109
/// This behavior listens to a key down event on the associated <see cref="UIElement"/> when it is loaded and executes an action.
1110
/// </summary>
1211
[TypeConstraint(typeof(FrameworkElement))]
13-
public class KeyDownTriggerBehavior : Trigger<UIElement>
12+
public class KeyDownTriggerBehavior : Trigger<FrameworkElement>
1413
{
1514

1615
/// <summary>
@@ -31,12 +30,6 @@ public VirtualKey Key
3130
set => SetValue(KeyProperty, value);
3231
}
3332

34-
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
35-
"Command",
36-
typeof(ICommand),
37-
typeof(KeyDownTriggerBehavior),
38-
new PropertyMetadata(null));
39-
4033
/// <inheritdoc/>
4134
protected override void OnAttached()
4235
{

0 commit comments

Comments
 (0)