SilverLight實現繞垂直中線翻轉效果

來源:互聯網
上載者:User

主要通過StoryBoard來控制PlaneProjection的RotationY來實現

 

XAML: 

    <Grid x:Name="LayoutRoot" Background="White"  Height="Auto" Width="Auto">

        <Grid.Resources>

        </Grid.Resources>

        <StackPanel>

            <UCTL:NavgationforZB x:Name="Navgation"></UCTL:NavgationforZB>

                <Grid  x:Name="ChartPanel" Height="Auto" Width="Auto"   >

            </Grid>

        </StackPanel>

    </Grid >

 

CS:

         private void Flip()

        {

            PlaneProjection pp = new PlaneProjection { CenterOfRotationY = .5, CenterOfRotationX=.5 };

            this.ChartPanel.Projection = pp;

            if (perSb != null)

            {

                perSb.Stop();

            }

            Storyboard sboard = new Storyboard();

            perSb = sboard;

            DoubleAnimation daAngle = new DoubleAnimation();

            daAngle.From = -180;

            daAngle.To = 0;

            daAngle.Duration = TimeSpan.FromSeconds(1);

            daAngle.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseOut, Power = 3 };

            Storyboard.SetTargetProperty(daAngle, new PropertyPath("RotationY"));

            Storyboard.SetTarget(daAngle, pp);

            sboard.Children.Add(daAngle);

            sboard.Begin();

        }

 

有幾點注意的地方:

1.  Storyboard.SetTarget(daAngle, pp); target 是PlaneProjection 的對象;

2.  執行Storyboard的Begin方法的時停止前一個Storyboard;

3.如果From 0 to 180來翻轉的話文字是橫向180反轉的,0 to 360 這樣的話就會轉兩圈,文字是正了,但是有個超級鬱悶的問題,文字模糊了。害我浪費了一天。

後來突發奇想改成 -180 to 0 居然OK了。汗==!!!! 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.