原文:重新想象 Windows 8 Store Apps (20) - 动画: ThemeAnimation(主题动画)

[源码下载]

重新想象 Windows 8 Store Apps (20) - 动画: ThemeAnimation(主题动画)

作者:webabcd

介绍
重新想象 Windows 8 Store Apps 之 动画

  • PopInThemeAnimation - 控件出现时的动画, PopOutThemeAnimation - 控件消失时的动画
  • FadeInThemeAnimation - 控件淡入的动画, FadeOutThemeAnimation - 控件淡出的动画
  • PointerDownThemeAnimation - 鼠标(手指)在控件上按下时的动画, PointerUpThemeAnimation - 鼠标(手指)在控件上抬起时的动画
  • SwipeHintThemeAnimation - 控件的 Swipe 动画(当你的控件在收到 Swipe 后会做响应时), SwipeBackThemeAnimation - 控件的 Swipe 动画(当你的控件在收到 Swipe 后不需要做任何响应时)
  • RepositionThemeAnimation - 控件重新定位时的动画
  • SplitOpenThemeAnimation - 打开“拆分”控件的动画, SplitCloseThemeAnimation - 关闭“拆分”控件的动画
  • DragItemThemeAnimation, DragOverThemeAnimation, DropTargetItemThemeAnimation - 顾名思义的一些动画效果,用于集合类的控件

示例
1、演示主题动画之 PopIn, PopOut
Animation/ThemeAnimation/PopInPopOut.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.PopInPopOut"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0">
<StackPanel.Resources>
<!--
PopInThemeAnimation - 控件出现时的动画
FromHorizontalOffset - 控件起始位置的水平偏移量
FromVerticalOffset - 控件起始位置的垂直偏移量
-->
<Storyboard x:Name="storyboardPopIn">
<PopInThemeAnimation Storyboard.TargetName="border" FromHorizontalOffset="1000" FromVerticalOffset="300" />
</Storyboard> <!--
PopOutThemeAnimation - 控件消失时的动画
-->
<Storyboard x:Name="storyboardPopOut">
<PopOutThemeAnimation Storyboard.TargetName="border" />
</Storyboard>
</StackPanel.Resources> <Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left">
<Border.Child>
<TextBlock Text="我是 Border 里的内容" FontSize="24.667" TextAlignment="Center" VerticalAlignment="Center" />
</Border.Child>
</Border> <Button Name="btnPopIn" Content="PopInThemeAnimation Demo" Click="btnPopIn_Click_1" Margin="0 30 0 0" />
<Button Name="btnPopOut" Content="PopOutThemeAnimation Demo" Click="btnPopOut_Click_1" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>

Animation/ThemeAnimation/PopInPopOut.xaml.cs

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace XamlDemo.Animation.ThemeAnimation
{
public sealed partial class PopInPopOut : Page
{
public PopInPopOut()
{
this.InitializeComponent();
} private void btnPopIn_Click_1(object sender, RoutedEventArgs e)
{
storyboardPopIn.Begin();
} private void btnPopOut_Click_1(object sender, RoutedEventArgs e)
{
storyboardPopOut.Begin();
}
}
}

2、演示主题动画之 FadeIn, FadeOut
Animation/ThemeAnimation/FadeInFadeOut.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.FadeInFadeOut"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0">
<StackPanel.Resources>
<!--
FadeInThemeAnimation - 控件淡入的动画
-->
<Storyboard x:Name="storyboardFadeIn">
<FadeInThemeAnimation Storyboard.TargetName="border" />
</Storyboard> <!--
FadeOutThemeAnimation - 控件淡出的动画
-->
<Storyboard x:Name="storyboardFadeOut">
<FadeOutThemeAnimation Storyboard.TargetName="border" />
</Storyboard>
</StackPanel.Resources> <Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left">
<Border.Child>
<TextBlock Text="我是 Border 里的内容" FontSize="24.667" TextAlignment="Center" VerticalAlignment="Center" />
</Border.Child>
</Border> <Button Name="btnFadeIn" Content="FadeInThemeAnimation Demo" Click="btnFadeIn_Click_1" Margin="0 10 0 0" />
<Button Name="btnFadeOut" Content="FadeOutThemeAnimation Demo" Click="btnFadeOut_Click_1" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>

Animation/ThemeAnimation/FadeInFadeOut.xaml.cs

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace XamlDemo.Animation.ThemeAnimation
{
public sealed partial class FadeInFadeOut : Page
{
public FadeInFadeOut()
{
this.InitializeComponent();
} private void btnFadeIn_Click_1(object sender, RoutedEventArgs e)
{
storyboardFadeIn.Begin();
} private void btnFadeOut_Click_1(object sender, RoutedEventArgs e)
{
storyboardFadeOut.Begin();
}
}
}

3、演示主题动画之 PointerDown, PointerUp
Animation/ThemeAnimation/PointerDownPointerUp.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.PointerDownPointerUp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0">
<StackPanel.Resources>
<!--
PointerDownThemeAnimation - 鼠标(手指)在控件上按下时的动画
-->
<Storyboard x:Name="storyboardPointerDown">
<PointerDownThemeAnimation Storyboard.TargetName="border" />
</Storyboard> <!--
PointerUpThemeAnimation - 鼠标(手指)在控件上抬起时的动画
-->
<Storyboard x:Name="storyboardPointerUp">
<PointerUpThemeAnimation Storyboard.TargetName="border" />
</Storyboard>
</StackPanel.Resources> <Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left">
<Border.Child>
<TextBlock Text="我是 Border 里的内容" FontSize="24.667" TextAlignment="Center" VerticalAlignment="Center" />
</Border.Child>
</Border> <Button Name="btnPointerDown" Content="PointerDownThemeAnimation Demo" Click="btnPointerDown_Click_1" Margin="0 10 0 0" />
<Button Name="btnPointerUp" Content="PointerUpThemeAnimation Demo" Click="btnPointerUp_Click_1" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>

Animation/ThemeAnimation/PointerDownPointerUp.xaml.cs

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace XamlDemo.Animation.ThemeAnimation
{
public sealed partial class PointerDownPointerUp : Page
{
public PointerDownPointerUp()
{
this.InitializeComponent();
} private void btnPointerDown_Click_1(object sender, RoutedEventArgs e)
{
storyboardPointerDown.Begin();
} private void btnPointerUp_Click_1(object sender, RoutedEventArgs e)
{
storyboardPointerUp.Begin();
}
}
}

4、演示主题动画之 SwipeHint, SwipeBack
Animation/ThemeAnimation/SwipeHintSwipeBack.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.SwipeHintSwipeBack"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0">
<StackPanel.Resources>
<!--
SwipeHintThemeAnimation - 控件的 Swipe 动画(当你的控件在收到 Swipe 后会做响应时)
ToHorizontalOffset, ToVerticalOffset - 控件需要到达的偏移量
-->
<Storyboard x:Name="storyboardSwipeHint">
<SwipeHintThemeAnimation Storyboard.TargetName="border" ToHorizontalOffset="100" ToVerticalOffset="100" />
</Storyboard> <!--
SwipeBackThemeAnimation - 控件的 Swipe 动画(当你的控件在收到 Swipe 后不需要做任何响应时)
FromHorizontalOffset, FromVerticalOffset - 控件从此偏移量返回原位
-->
<Storyboard x:Name="storyboardSwipeBack">
<SwipeBackThemeAnimation Storyboard.TargetName="border" FromHorizontalOffset="100" FromVerticalOffset="100" />
</Storyboard>
</StackPanel.Resources> <Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left">
<Border.Child>
<TextBlock Text="我是 Border 里的内容" FontSize="24.667" TextAlignment="Center" VerticalAlignment="Center" />
</Border.Child>
</Border> <Button Name="btnSwipeHint" Content="SwipeHintThemeAnimation Demo" Click="btnSwipeHint_Click_1" Margin="0 10 0 0" />
<Button Name="btnSwipeBack" Content="SwipeBackThemeAnimation Demo" Click="btnSwipeBack_Click_1" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>

Animation/ThemeAnimation/SwipeHintSwipeBack.xaml.cs

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace XamlDemo.Animation.ThemeAnimation
{
public sealed partial class SwipeHintSwipeBack : Page
{
public SwipeHintSwipeBack()
{
this.InitializeComponent();
} private void btnSwipeHint_Click_1(object sender, RoutedEventArgs e)
{
storyboardSwipeHint.Begin();
} private void btnSwipeBack_Click_1(object sender, RoutedEventArgs e)
{
storyboardSwipeBack.Begin();
}
}
}

5、演示主题动画之 Reposition
Animation/ThemeAnimation/Reposition.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.Reposition"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0">
<StackPanel.Resources>
<!--
RepositionThemeAnimation - 控件重新定位时的动画
FromHorizontalOffset, FromVerticalOffset - 控件从此偏移量的位置重新定位到新的位置
-->
<Storyboard x:Name="storyboardReposition">
<RepositionThemeAnimation Storyboard.TargetName="border" FromHorizontalOffset="1000" FromVerticalOffset="300" />
</Storyboard>
</StackPanel.Resources> <Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left">
<Border.Child>
<TextBlock Text="我是 Border 里的内容" FontSize="24.667" TextAlignment="Center" VerticalAlignment="Center" />
</Border.Child>
</Border> <Button Name="btnReposition" Content="RepositionThemeAnimation Demo" Click="btnReposition_Click_1" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>

Animation/ThemeAnimation/Reposition.xaml.cs

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace XamlDemo.Animation.ThemeAnimation
{
public sealed partial class Reposition : Page
{
public Reposition()
{
this.InitializeComponent();
} private void btnReposition_Click_1(object sender, RoutedEventArgs e)
{
storyboardReposition.Begin();
}
}
}

6、演示主题动画之 SplitOpen, SplitClose
Animation/ThemeAnimation/SplitOpenSplitClose.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.SplitOpenSplitClose"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0">
<StackPanel.Resources>
<!--
SplitOpenThemeAnimation - 打开“拆分”控件的动画
打开 OpenedTargetName(OpenedTargetName 的内容是 ContentTargetName),关闭 ClosedTargetName 具体的用法参见 ComboBox 的 ControlTemplate
-->
<Storyboard x:Name="storyboardSplitOpen">
<SplitOpenThemeAnimation
OpenedTargetName="border"
ContentTargetName="textBlock"
ClosedTargetName="rectangle"
ContentTranslationDirection="Left"
ContentTranslationOffset="200"
OffsetFromCenter="0"
OpenedLength="1"
ClosedLength="0" />
</Storyboard> <!--
SplitCloseThemeAnimation - 关闭“拆分”控件的动画
关闭 OpenedTargetName(OpenedTargetName 的内容是 ContentTargetName),打开 ClosedTargetName 具体的用法参见 ComboBox 的 ControlTemplate
-->
<Storyboard x:Name="storyboardSplitClose">
<SplitCloseThemeAnimation
OpenedTargetName="border"
ContentTargetName="textBlock"
ClosedTargetName="rectangle"
ContentTranslationDirection="Left"
ContentTranslationOffset="200"
OffsetFromCenter="0"
OpenedLength="1"
ClosedLength="0" />
</Storyboard>
</StackPanel.Resources> <Rectangle Name="rectangle" Width="400" Height="100" Fill="Orange" HorizontalAlignment="Left" />
<Border Name="border" BorderThickness="5" BorderBrush="Red" Background="Blue" CornerRadius="10" Width="400" Height="100" HorizontalAlignment="Left" /> <Button Name="btnSplitOpen" Content="SplitOpenThemeAnimation Demo" Click="btnSplitOpen_Click_1" Margin="0 10 0 0" />
<Button Name="btnSplitClose" Content="SplitCloseThemeAnimation Demo" Click="btnSplitClose_Click_1" Margin="0 10 0 0" /> </StackPanel>
</Grid>
</Page>

Animation/ThemeAnimation/SplitOpenSplitClose.xaml.cs

using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace XamlDemo.Animation.ThemeAnimation
{
public sealed partial class SplitOpenSplitClose : Page
{
public SplitOpenSplitClose()
{
this.InitializeComponent();
} private void btnSplitOpen_Click_1(object sender, RoutedEventArgs e)
{
TextBlock textBlock = new TextBlock();
textBlock.Name = "textBlock";
textBlock.Text = "我是 Border 里的内容";
textBlock.FontSize = 24.667;
textBlock.TextAlignment = TextAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Center; border.Child = textBlock; storyboardSplitOpen.Begin();
} private void btnSplitClose_Click_1(object sender, RoutedEventArgs e)
{
storyboardSplitClose.Begin();
}
}
}

7、演示主题动画之 DragItem, DragOver, DropTargetItem
Animation/ThemeAnimation/DragItemDragOverDropTargetItem.xaml

<Page
x:Class="XamlDemo.Animation.ThemeAnimation.DragItemDragOverDropTargetItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:XamlDemo.Animation.ThemeAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="120 0 0 0"> <TextBlock FontSize="14.667" LineHeight="22">
<Run>顾名思义的 DragItemThemeAnimation, DragOverThemeAnimation, DropTargetItemThemeAnimation</Run>
<LineBreak />
<Run>具体的用法参见 GridViewItem 或 ListViewItem 的 ControlTemplate</Run>
</TextBlock> </StackPanel>
</Grid>
</Page>

OK
[源码下载]

重新想象 Windows 8 Store Apps (20) - 动画: ThemeAnimation(主题动画)的更多相关文章

  1. 重新想象 Windows 8 Store Apps 系列文章索引

    [源码下载][重新想象 Windows 8.1 Store Apps 系列文章] 重新想象 Windows 8 Store Apps 系列文章索引 作者:webabcd 1.重新想象 Windows ...

  2. 重新想象 Windows 8 Store Apps (19) - 动画: 线性动画, 关键帧动画, 缓动动画

    原文:重新想象 Windows 8 Store Apps (19) - 动画: 线性动画, 关键帧动画, 缓动动画 [源码下载] 重新想象 Windows 8 Store Apps (19) - 动画 ...

  3. 重新想象 Windows 8 Store Apps (21) - 动画: ThemeTransition(过渡效果)

    原文:重新想象 Windows 8 Store Apps (21) - 动画: ThemeTransition(过渡效果) [源码下载] 重新想象 Windows 8 Store Apps (21) ...

  4. 重新想象 Windows 8 Store Apps (56) - 系统 UI: Scale, Snap, Orientation, High Contrast 等

    [源码下载] 重新想象 Windows 8 Store Apps (56) - 系统 UI: Scale, Snap, Orientation, High Contrast 等 作者:webabcd ...

  5. 重新想象 Windows 8 Store Apps (41) - 打印

    [源码下载] 重新想象 Windows 8 Store Apps (41) - 打印 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 打印 示例1.需要打印的文档Pr ...

  6. 重新想象 Windows 8 Store Apps (48) - 多线程之其他辅助类: SpinWait, SpinLock, Volatile, SynchronizationContext, CoreDispatcher, ThreadLocal, ThreadStaticAttribute

    [源码下载] 重新想象 Windows 8 Store Apps (48) - 多线程之其他辅助类: SpinWait, SpinLock, Volatile, SynchronizationCont ...

  7. 重新想象 Windows 8 Store Apps (55) - 绑定: MVVM 模式

    [源码下载] 重新想象 Windows 8 Store Apps (55) - 绑定: MVVM 模式 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 绑定 通过 M ...

  8. 重新想象 Windows 8 Store Apps (62) - 通信: Socket TCP, Socket UDP

    [源码下载] 重新想象 Windows 8 Store Apps (62) - 通信: Socket TCP, Socket UDP 作者:webabcd 介绍重新想象 Windows 8 Store ...

  9. 重新想象 Windows 8 Store Apps (63) - 通信: WebSocket

    [源码下载] 重新想象 Windows 8 Store Apps (63) - 通信: WebSocket 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 通信 So ...

随机推荐

  1. 《转》Frameset布局

    前二天在写一个HTML界面,用到了Frameset,主要学习都是在下面的文章里,内容写得很详细,值得推荐大家看下. 网址:http://captaincook.iteye.com/blog/36563 ...

  2. 去掉chrome记住密码后自动填充表单的黄色背景

    chrome表单自动填充后,input文本框的背景会变成黄色的,通过审查元素可以看到这是由于chrome会默认给自动填充的input表单加上input:-webkit-autofill私有属性,然后对 ...

  3. Load and Unload

    一.前言 在前一段时间,我遭遇了一个现象诡异的Bug,最后原因归结为在DllMain里错误地调用了FreeLibrary(在本文最后对此Bug有详细的解释). MSDN里关于禁止在DllMain里调用 ...

  4. FZU2176(二维线段树+dfs)

    传送门:easy problem 题意:给定一棵n个节点以1为根的树,初始每个节点的值为0,现在我们要在树上进行一些操作,操作有两种类型. 1 x val 表示对以x为根的子树的每个点进行加权操作(我 ...

  5. GIS Tools for Hadoop 详细介绍

    2013年Esri美国在开发者大会上演示了GIS数据结合Hadoop分析的一个示例,这个示例赢得了听众的阵阵掌声,我们也许对GIS不是很陌生,但是对Hadoop却不是很清楚,其实Esri是用Java开 ...

  6. hdu1505(dp求最大子矩阵)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1505 分析: 这题是HDU 1506 的加强版,定义一个二维数组,d[i][j]表示第i行j列元素在前 ...

  7. 【译】ASP.NET MVC 5 教程 - 2:添加控制器

    原文:[译]ASP.NET MVC 5 教程 - 2:添加控制器 MVC 表示 模型-视图-控制器.MVC 是一种用于开发应用程序的模式,具备良好架构,可测试和易于维护.基于 MVC 应用程序中包含: ...

  8. 查看mysql一些命令的数据库状态

    命令: show processlist;  假设是root帐号,你能看到全部用户的当前连接.假设是其他普通帐号,仅仅能看到自己占用的连接.   show processlist;仅仅列出前100条, ...

  9. TSL230选型

    tsl230是一种可以直接将光强转化成频率值的器件.详细原理就不介绍了,数据手冊里写的都非常清楚,230系列包括非常多种,主要为下面四类:TSL230,TSL230A,TSL230B系列:TSL230 ...

  10. Learning React Native笔记

    React Native作为一个新事物,相关的资料还不多 官方的文档比较简单,缺少一些系统的例子 在对React Native的应用中,迫切的想学习一些别人的最佳实践.所以想通过看书系统的学习下 之前 ...