Skip to content

Commit 129ab97

Browse files
committed
Added VisualExtensions.Translation samples
1 parent c47b47b commit 129ab97

File tree

2 files changed

+63
-6
lines changed

2 files changed

+63
-6
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Visual Extensions/VisualExtensionsCode.bind

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,49 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
8+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
9+
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
10+
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
11+
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
812
mc:Ignorable="d">
913

10-
<Grid>
14+
<StackPanel Spacing="120" VerticalAlignment="Center">
15+
16+
<!--This is a static element, with some Visual properties being modified through
17+
the VisualExtensions class. You can modify their values to see how the position,
18+
orientation and alignment of the Border element changes.-->
1119
<Border Height="100"
1220
Width="100"
1321
Background="Purple"
22+
ui:VisualExtensions.CenterPoint="50,50,0"
23+
ui:VisualExtensions.Offset="50"
1424
ui:VisualExtensions.Opacity="0.5"
1525
ui:VisualExtensions.RotationAngleInDegrees="80"
1626
ui:VisualExtensions.Scale="2, 0.5, 1"
17-
ui:VisualExtensions.NormalizedCenterPoint="0.5" />
18-
</Grid>
27+
ui:VisualExtensions.NormalizedCenterPoint="0.5"
28+
ui:VisualExtensions.Translation="20,12,0"/>
29+
30+
<!--This Button demonstrates the VisualExtensions.Translation property in combination with a translation
31+
animation. The Translation property is set to indicate the starting position of the element (relative
32+
to its offset), and the animation will modify that to reach the specified translation value. Note how
33+
the animation doesn't have an explicit starting value, as it will just start animating the translation
34+
from the current value set via the VisualExtensions.Translation attached property.-->
35+
<Button Height="120"
36+
Width="360"
37+
Background="Green"
38+
Content="Click me!"
39+
FontSize="32"
40+
ui:VisualExtensions.Translation="20,-40,0">
41+
<ani:Explicit.Animations>
42+
<ani:AnimationSet x:Name="MoveAnimation">
43+
<ani:TranslationAnimation To="480,80,0" Duration="0:0:2"/>
44+
</ani:AnimationSet>
45+
</ani:Explicit.Animations>
46+
<interactivity:Interaction.Behaviors>
47+
<interactions:EventTriggerBehavior EventName="Click">
48+
<behaviors:StartAnimationAction Animation="{Binding ElementName=MoveAnimation}"/>
49+
</interactions:EventTriggerBehavior>
50+
</interactivity:Interaction.Behaviors>
51+
</Button>
52+
</StackPanel>
1953
</Page>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Visual Extensions/VisualExtensionsPage.xaml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
6+
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
7+
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
8+
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
9+
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
610
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
711
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
812
mc:Ignorable="d">
913

10-
<Grid>
14+
<StackPanel Spacing="120" VerticalAlignment="Center">
1115
<Border Height="100"
1216
Width="100"
1317
Background="Purple"
@@ -16,6 +20,25 @@
1620
ui:VisualExtensions.Opacity="0.5"
1721
ui:VisualExtensions.RotationAngleInDegrees="80"
1822
ui:VisualExtensions.Scale="2, 0.5, 1"
19-
ui:VisualExtensions.NormalizedCenterPoint="0.5"/>
20-
</Grid>
23+
ui:VisualExtensions.NormalizedCenterPoint="0.5"
24+
ui:VisualExtensions.Translation="20,12,0"/>
25+
<Button
26+
Height="120"
27+
Width="360"
28+
Background="Green"
29+
Content="Click me!"
30+
FontSize="32"
31+
ui:VisualExtensions.Translation="20,-40,0">
32+
<ani:Explicit.Animations>
33+
<ani:AnimationSet x:Name="MoveAnimation">
34+
<ani:TranslationAnimation To="480,80,0" Duration="0:0:2"/>
35+
</ani:AnimationSet>
36+
</ani:Explicit.Animations>
37+
<interactivity:Interaction.Behaviors>
38+
<interactions:EventTriggerBehavior EventName="Click">
39+
<behaviors:StartAnimationAction Animation="{Binding ElementName=MoveAnimation}"/>
40+
</interactions:EventTriggerBehavior>
41+
</interactivity:Interaction.Behaviors>
42+
</Button>
43+
</StackPanel>
2144
</Page>

0 commit comments

Comments
 (0)