[Windows Phone] 自己動手實現Telerik公司的LayoutTransform動畫效果

來源:互聯網
上載者:User

[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

 

——完。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.