/
HandoffVersusComposeExample.xaml
61 lines (61 loc) · 2.56 KB
/
HandoffVersusComposeExample.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AnimationTiming.HandoffVersusComposeExample">
<Page.Resources>
<Storyboard x:Key="FadeToHalf">
<DoubleAnimation To="0.5" Duration="0:0:1.0"
Storyboard.TargetProperty="Fill.Opacity" />
<DoubleAnimation To="45" Duration="0:0:1.0"
Storyboard.TargetProperty="Height" />
</Storyboard>
<Storyboard x:Key="FadeToFull">
<DoubleAnimation Duration="0:0:1.0"
Storyboard.TargetProperty="Fill.Opacity" />
<DoubleAnimation Duration="0:0:1.0"
Storyboard.TargetProperty="Height" />
</Storyboard>
<Style x:Key="Compose" TargetType="{x:Type Rectangle}">
<Setter Property="Fill" Value="Red" />
<Setter Property="Width" Value="90" />
<Setter Property="Height" Value="90" />
<Style.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource FadeToHalf}" HandoffBehavior="Compose"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Mouse.MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource FadeToFull}" HandoffBehavior="Compose"/>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
<Style x:Key="Handoff" TargetType="{x:Type Rectangle}">
<Setter Property="Fill" Value="Blue" />
<Setter Property="Width" Value="90" />
<Setter Property="Height" Value="90" />
<Style.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource FadeToHalf}" HandoffBehavior="SnapshotAndReplace"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Mouse.MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource FadeToFull}" HandoffBehavior="SnapshotAndReplace"/>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Page.Resources>
<Canvas Background="White">
<TextBlock Canvas.Top="50" Canvas.Left="100" Foreground="Red">Compose</TextBlock>
<TextBlock Canvas.Top="50" Canvas.Left="200" Foreground="Blue">SnapshotAndReplace</TextBlock>
<Rectangle Style="{StaticResource Handoff}" Canvas.Top="100" Canvas.Left="100" />
<Rectangle Style="{StaticResource Compose}" Canvas.Top="100" Canvas.Left="200" />
<Rectangle Style="{StaticResource Compose}" Canvas.Top="200" Canvas.Left="100" />
<Rectangle Style="{StaticResource Handoff}" Canvas.Top="200" Canvas.Left="200" />
</Canvas>
</Page>