windows8開發-metro應用中頁面漸入效果(透明度)

來源:互聯網
上載者:User

在自訂的Page或者基類LayoutAwarePage(如果繼承了這個類的話)的OnNavigateTo事件中,可以定義這麼一個動畫效果:

修改頁面的透明度,從透明漸層為不透明。

建議盡量使用基於LayoutAwarePage(基本頁)的頁面Page,因為許多導航的功能以及頁面生命週期的管理都已經封裝得比較完善了。在頁面的跳轉過程中,利用其提供的LoadState()和SaveState()可以做頁面參數的傳遞以及緩衝。

說偏了,下面是一個比較簡單的動畫效果:

        /// <summary>        /// 建立進入視圖時的漸層動畫        /// </summary>        private void ShowNavigationStoryBoard()        {            Storyboard story = new Storyboard();            DoubleAnimation animation;            animation = new DoubleAnimation();            animation.From = 0.3;            animation.To = 1;            animation.Duration = new Duration(TimeSpan.FromMilliseconds(300));            Storyboard.SetTarget(animation, this);            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.Opacity)").Path);            story.Children.Add(animation);            story.Begin();        }

其中,ShowNavigationStoryBoard()這個方法我寫到了OnNavigateTo事件裡面。

相關文章

聯繫我們

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