新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C++實(shí)現(xiàn)WPF動(dòng)畫具體操作方法詳解
C++編程語言的應(yīng)方式非常廣泛,可以幫助我們輕松的實(shí)現(xiàn)許多功能需求。比如今天為大家介紹有關(guān)C++實(shí)現(xiàn)WPF動(dòng)畫的相關(guān)操作,就可以以一種簡單的方式來實(shí)現(xiàn)。下面就讓我們一起來看看具體的操作方法吧。#t#

很多人都習(xí)慣使用Blend來幫助編輯XAML文件,生成很多動(dòng)畫。但在實(shí)際開發(fā)中,用代碼來實(shí)現(xiàn)動(dòng)畫還是很實(shí)用的,而且代碼的邏輯開發(fā)能力更強(qiáng),更容易控制,這方面C#的例子已經(jīng)很多了,下面我介紹幾個(gè)C++實(shí)現(xiàn)WPF動(dòng)畫的例子。
首先介紹少漸隱漸現(xiàn),也就是Alpha Animation。C++實(shí)現(xiàn)WPF動(dòng)畫代碼如下
- /**//*
- * Take Label for example
- */
- // 1, Find the lable by its name, The name define in the xaml file
- Label^ pColorLabel = (Label^)page->FindName("ColorAnimationLabel");
- // 2, Define a DoubleAnimation object
- DoubleAnimation^ pDoubleAnimation = gcnew DoubleAnimation();
- // 3, Set from to and duration
- pDoubleAnimation->From = 1;
- pDoubleAnimation->To = 0;
- pDoubleAnimation->DurationDuration = Duration(TimeSpan::FromSeconds(3));
- // 4, Create a storyboard(Timeline)
- Storyboard^ pStoryboard = gcnew Storyboard();
- // 5, Set the DoubleAnimation's target name
- pStoryboard->SetTargetName(pDoubleAnimation, _T("ColorAnimationLabel"));
- // 6, Set the DoubleAnimation's property
- pStoryboard->SetTargetProperty(pDoubleAnimation,
gcnew PropertyPath(Label::OpacityProperty));- // 7, Add the DoubleAnimation object to the storyboard
- pStoryboard->Children->Add(pDoubleAnimation);
- // 8, Start the animation
- pStoryboard->Begin(pColorLabel);
上面C++實(shí)現(xiàn)WPF動(dòng)畫代碼所用的XAML如下
- < Page
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- >
- < Grid>
- < DockPanel>
- < Button Name="ColorAnmationButton" Width="100" Height="50"
Background="LightBlue">Color Anmation< /Button>- < Label Name="ColorAnimationLabel" Width="200"
Height="50" Background="Red">- < /Label>
- < /DockPanel>
- < /Grid>
- < /Page>
以上就是對(duì)C++實(shí)現(xiàn)WPF動(dòng)畫的相關(guān)操作介紹。
網(wǎng)站題目:C++實(shí)現(xiàn)WPF動(dòng)畫具體操作方法詳解
當(dāng)前網(wǎng)址:http://www.dlmjj.cn/article/coddgpo.html


咨詢
建站咨詢
