[Windows Phone] 自己动手实现Telerik公司的LayoutTransform动画效果
[Windows Phone] 自己动手实现Telerik公司的LayoutTransform动画效果
作者:sinodragon21/Nathan
转载请注明出处 http://www.cnblogs.com/sinodragon21/archive/2012/07/20/2601164.html
一、Demo截图效果
二、核心代码
1 public void OnPropertyChanged(Object sender, PropertyChangedEventArgs args) 2 { 3 //Rect tmp = _layoutTransform.TransformBounds(((Rect)_content)); 4 if (null == _content) 5 { 6 return; 7 } 8 9 _content.RenderTransform = _layoutTransform; 10 CompositeTransform tmp = (CompositeTransform) _layoutTransform; 11 double radian = tmp.Rotation * Math.PI / 180; 12 double d = (_content.Width) * (System.Math.Sin(radian) + System.Math.Cos(radian)); 13 double margin = Math.Abs((d - _content.Width)/2); 14 _content.Margin = new Thickness(margin); 15 }
1 <phone:PhoneApplicationPage 2 x:Name="Myself" 3 x:Class="LayoutTransform.MainPage" 4 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 5 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 6 xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 7 xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 8 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 9 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 10 xmlns:system="clr-namespace:System;assembly=mscorlib" 11 xmlns:layouttransform="clr-namespace:LayoutTransform;assembly=LayoutTransform" 12 mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" 13 FontFamily="{StaticResource PhoneFontFamilyNormal}" 14 FontSize="{StaticResource PhoneFontSizeNormal}" 15 Foreground="{StaticResource PhoneForegroundBrush}" 16 SupportedOrientations="Portrait" Orientation="Portrait" 17 shell:SystemTray.IsVisible="True"> 18 19 <phone:PhoneApplicationPage.Resources> 20 <system:Double x:Key="MyFontSizeAppName">24</system:Double> 21 <FontFamily x:Key="MyFontFamilySemiBold">Segoe WP Semibold</FontFamily> 22 23 <Style x:Key="MyAppNameTextBlockStyle" TargetType="TextBlock"> 24 <Setter Property="FontFamily" Value="{StaticResource MyFontFamilySemiBold}"/> 25 <Setter Property="FontSize" Value="{StaticResource MyFontSizeAppName}"/> 26 <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/> 27 <Setter Property="Margin" Value="12,10,12,10" /> 28 </Style> 29 30 <Storyboard x:Name="sb_protagonist"> 31 <DoubleAnimation Storyboard.TargetName="Myself" 32 Storyboard.TargetProperty="Rotation" 33 From="0" To="360" Duration="0:0:5" /> 34 </Storyboard> 35 </phone:PhoneApplicationPage.Resources>
三、源代码下载地址
http://www.hugwp.com/thread-4208-1.html
——完。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异