WPF圆形环绕的Loading动画

本文介绍了如何在WPF中创建一个类似Silverlight和Win8系统的加载动画效果,主要利用了ellipse元素。虽然可以通过 Blend 达到更佳效果,但基础实现只需XAML代码。
摘要由CSDN通过智能技术生成

WPF制作一个模仿Silverlight页面还有win8系统的Loading动画效果,其实就用到WPF的ellipse即可,如果想要简单或者更好的效果的话还是要用Blend去做哈。

xaml代码:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="Loading动画.Window1" x:Name="Window" Title="Window1" Width="640" Height="480" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        mc:Ignorable="d">
    <Window.Resources>
        <Storyboard x:Key="Storyboard1">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse1">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse2">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse3">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.3000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse4">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.4000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse5">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse6">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.1000000" Value="1" />
                <SplineDoubleKeyFrame KeyTime="00:00:01.6000000" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:02.7000000" Value="0" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" RepeatBehavior="Forever" Storyboard.TargetName="ellipse7">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                <SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="0" />
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值