WPF and Expression Blend development examples: loading animations

Source: Internet
Author: User

Today, a little practical, the project can be used in real, a loading animation, and finally encapsulated into a control, can be used directly in the project, first:

The whole design is simple, it is to draw 18 path on the interface, then change the value of OpacityMask by animation to achieve a dynamic effect.

Because the whole process is relatively simple, so there is no use of blend, the only thing to be aware of is path value is to be generated from PS, the path is as follows:

<x:key= "Block">            m291.15499,85.897525             C291.15499, 85.897525              301.88917,85.87921              301.88917,85.87921              301.88917,85.87921              300.38339,94.355061              300.38339,94.355061              300.38339,94.355061              292.85366,94.355042              292.85366,94.355042              292.85366,94.355042              291.15499,85.897525              291.15499,85.897525z</Geometry >

The code for path is as follows, and each path rotates at a specific angle around a circle

<Pathx:name= "Block0"Style="{StaticResource Pathstyle}"Data="{StaticResource Block}"OpacityMask= "#00000000" >     <Path.rendertransform>           <RotateTransformAngle= " the"/>      </Path.rendertransform></Path>
<Stylex:key= "Pathstyle"TargetType= "Path">            <Setter Property= "Fill"Value= "#FF0092FF"></Setter>            <Setter Property= "Stretch"Value= "Fill"></Setter>            <Setter Property= "Rendertransformorigin"Value= "0.5,5"></Setter>            <Setter Property= "VerticalAlignment"Value= "Top"></Setter>            <Setter Property= "Height"Value= "+"></Setter></Style>

Animation of a single path:

<ColorAnimationUsingKeyFramesDuration= "00:00:03.6"Storyboard.TargetName= "Block0"Storyboard.TargetProperty= "(Uielement.opacitymask). (Solidcolorbrush.color) ">                <LinearColorKeyFrameKeyTime= "00:00:00.0"Value= "#FF000000"/>                <LinearColorKeyFrameKeyTime= "00:00:00.2"Value= "#EF000000"/>                <LinearColorKeyFrameKeyTime= "00:00:00.4"Value= "#E2000000"/>                <LinearColorKeyFrameKeyTime= "00:00:00.6"Value= "#D3000000"/>                <LinearColorKeyFrameKeyTime= "00:00:00.8"Value= "#C6000000"/>                <LinearColorKeyFrameKeyTime= "00:00:01.0"Value= "#B7000000"/>                <LinearColorKeyFrameKeyTime= "00:00:01.2"Value= "#AA000000"/>                <LinearColorKeyFrameKeyTime= "00:00:01.4"Value= "#9B000000"/>                <LinearColorKeyFrameKeyTime= "00:00:01.6"Value= "#8E000000"/>                <LinearColorKeyFrameKeyTime= "00:00:01.8"Value= "#7F000000"/>                <LinearColorKeyFrameKeyTime= "00:00:02.0"Value= "#72000000"/>                <LinearColorKeyFrameKeyTime= "00:00:02.2"Value= "#63000000"/>                <LinearColorKeyFrameKeyTime= "00:00:02.4"Value= "#56000000"/>                <LinearColorKeyFrameKeyTime= "00:00:02.6"Value= "#3D000000"/>                <LinearColorKeyFrameKeyTime= "00:00:02.8"Value= "#26000000"/>                <LinearColorKeyFrameKeyTime= "00:00:03.0"Value= "#19000000"/>                <LinearColorKeyFrameKeyTime= "00:00:03.2"Value= "#0C000000"/>                <LinearColorKeyFrameKeyTime= "00:00:03.4"Value= "#00000000"/>                <LinearColorKeyFrameKeyTime= "00:00:03.6"Value= "#FF000000"/>            </ColorAnimationUsingKeyFrames>

Source code Download:

Http://files.cnblogs.com/youngytj/LoadingAnimations.rar

WPF and Expression Blend development examples: loading animations

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.