Examples of line-drawn animation effects implemented by WPF and those of wpf

Source: Internet
Author: User

Examples of line-drawn animation effects implemented by WPF and those of wpf
This article provides examples to share with you the specific code for implementing line-drawn animation in WPF for your reference. The specific content is as follows:

Requirement: a straight line (not a curve) is drawn gradually on the canvas like a model stroke. However, the premise is that it is implemented using background code instead of the WPF tag.

Effect:

Code:

///// Interaction logic of 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 );}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.