本篇文章給大家分享的是有關(guān)WPF中怎么實(shí)現(xiàn)畫線動(dòng)畫效果,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
目前創(chuàng)新互聯(lián)建站已為1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、建昌網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。上代碼:
////// Window2.xaml 的交互邏輯 /// public partial class Window2 : Window { public Window2() { InitializeComponent(); var canvas = new Canvas(); Content = canvas; var points = new List() { new Point(10, 10), new Point(90, 90), new Point(60, 10), new Point(250, 90), new Point(10, 10) }; var sb = new Storyboard(); for (int i = 0; i < points.Count - 1; i++) { var lineGeometry = new LineGeometry(points[i], points[i]); var path = new Path() { Stroke = Brushes.Black, StrokeThickness = 2, Data = lineGeometry }; canvas.Children.Add(path); var animation = new PointAnimation(points[i], points[i + 1], new Duration(TimeSpan.FromMilliseconds(1000))) { BeginTime = TimeSpan.FromMilliseconds(i * 1010) }; sb.Children.Add(animation); RegisterName("geometry" + i, lineGeometry); Storyboard.SetTargetName(animation, "geometry" + i); Storyboard.SetTargetProperty(animation, new PropertyPath(LineGeometry.EndPointProperty)); } MouseDown += (s, e) => sb.Begin(this); } }
以上就是WPF中怎么實(shí)現(xiàn)畫線動(dòng)畫效果,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。