本篇文章為大家展示了C++實現(xiàn)WPF動畫的具體操作方法,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
公司主營業(yè)務(wù):網(wǎng)站建設(shè)、成都做網(wǎng)站、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)建站是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)建站推出溫嶺免費做網(wǎng)站回饋大家。
C++編程語言的應(yīng)方式非常廣泛,可以幫助我們輕松的實現(xiàn)許多功能需求。
很多人都習(xí)慣使用Blend來幫助編輯XAML文件,生成很多動畫。但在實際開發(fā)中,用代碼來實現(xiàn)動畫還是很實用的,而且代碼的邏輯開發(fā)能力更強,更容易控制,這方面C#的例子已經(jīng)很多了,下面我介紹幾個C++實現(xiàn)WPF動畫的例子。
首先介紹少漸隱漸現(xiàn),也就是Alpha Animation。C++實現(xiàn)WPF動畫代碼如下
/**//*
* 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++實現(xiàn)WPF動畫代碼所用的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>
上述內(nèi)容就是C++實現(xiàn)WPF動畫的具體操作方法,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)站欄目:C++實現(xiàn)WPF動畫的具體操作方法
文章來源:http://www.chinadenli.net/article12/gpecdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、微信小程序、網(wǎng)站內(nèi)鏈、外貿(mào)建站、軟件開發(fā)、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)