资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

C++实现WPF动画的具体操作方法

本篇文章为大家展示了C++实现WPF动画的具体操作方法,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

公司主营业务:网站建设、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出温岭免费做网站回馈大家。

C++编程语言的应方式非常广泛,可以帮助我们轻松的实现许多功能需求。

很多人都习惯使用Blend来帮助编辑XAML文件,生成很多动画。但在实际开发中,用代码来实现动画还是很实用的,而且代码的逻辑开发能力更强,更容易控制,这方面C#的例子已经很多了,下面我介绍几个C++实现WPF动画的例子。

首先介绍少渐隐渐现,也就是Alpha Animation。C++实现WPF动画代码如下

  1. /**//*  

  2. * Take Label for example  

  3. */  

  4. // 1, Find the lable by its name, The name define in the xaml file  

  5. Label^ pColorLabel = (Label^)page->FindName("ColorAnimationLabel");  

  6. // 2, Define a DoubleAnimation object  

  7. DoubleAnimation^ pDoubleAnimation = gcnew DoubleAnimation();  

  8. // 3, Set from to and duration  

  9. pDoubleAnimation->From = 1;  

  10. pDoubleAnimation->To = 0;  

  11. pDoubleAnimation->DurationDuration = Duration(TimeSpan::FromSeconds(3));  

  12. // 4, Create a storyboard(Timeline)  

  13. Storyboard^ pStoryboard = gcnew Storyboard();  

  14. // 5, Set the DoubleAnimation's target name  

  15. pStoryboard->SetTargetName(pDoubleAnimation, _T("ColorAnimationLabel"));  

  16. // 6, Set the DoubleAnimation's property  

  17. pStoryboard->SetTargetProperty(pDoubleAnimation, 
    gcnew PropertyPath(Label::OpacityProperty));  

  18. // 7, Add the DoubleAnimation object to the storyboard  

  19. pStoryboard->Children->Add(pDoubleAnimation);  

  20. // 8, Start the animation  

  21. pStoryboard->Begin(pColorLabel); 

上面C++实现WPF动画代码所用的XAML如下

  1. < Page 

  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 

  4. < Grid> 

  5. < DockPanel> 

  6. < Button Name="ColorAnmationButton" Width="100" Height="50" 
    Background="LightBlue">Color Anmation< /Button> 

  7. < Label Name="ColorAnimationLabel" Width="200" 
    Height="50" Background="Red"> 

  8. < /Label> 

  9. < /DockPanel> 

  10. < /Grid> 

  11. < /Page> 

上述内容就是C++实现WPF动画的具体操作方法,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。


文章标题:C++实现WPF动画的具体操作方法
文章出自:http://cdkjz.cn/article/gpecdc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220