现在位置首页 / 项目实战 /正文

wpf 闪烁红绿灯demo

作者: IT小兵 | 2016年10月19日| 热度:℃ | 评论: |参与:

先看效果图

启动程序后就可以自动闪烁

demo代码:

<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication3"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" Background="#FF292C14">
    <Window.Resources>
        <Storyboard x:Key="Storyboard1" RepeatBehavior="Forever">
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ellipse">
                <DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Hidden}"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
        </EventTrigger>
    </Window.Triggers>
    <Grid>
        <Viewbox Margin="0" Stretch="Fill" HorizontalAlignment="Right" Width="209" Height="209" VerticalAlignment="Top">
            <Grid Height="75.5" Width="75.5">
                <Ellipse RenderTransformOrigin="0.5,0.5">
                    <Ellipse.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="90.269"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Ellipse.RenderTransform>
                    <Ellipse.Fill>
                        <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                            <GradientStop Color="#FFC7C1C1" Offset="0"/>
                            <GradientStop Color="White" Offset="1"/>
                            <GradientStop Color="#FFE0E0E0" Offset="0.18"/>
                            <GradientStop Color="#FF959191" Offset="0.335"/>
                            <GradientStop Color="#FFE4DEDE" Offset="0.51"/>
                            <GradientStop Color="#FF8B8B8B" Offset="0.674"/>
                            <GradientStop Color="#FFF1F0F0" Offset="0.854"/>
                        </LinearGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
                <Ellipse Margin="3.5" RenderTransformOrigin="0.5,0.5">
                    <Ellipse.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="-73.856"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Ellipse.RenderTransform>
                    <Ellipse.Fill>
                        <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                            <GradientStop Color="#FFC7C1C1" Offset="0"/>
                            <GradientStop Color="White" Offset="1"/>
                            <GradientStop Color="#FFEEECEC" Offset="0.18"/>
                            <GradientStop Color="#FF959191" Offset="0.335"/>
                            <GradientStop Color="#FFE4DEDE" Offset="0.51"/>
                            <GradientStop Color="#FF8B8B8B" Offset="0.674"/>
                            <GradientStop Color="#FFF1F0F0" Offset="0.854"/>
                        </LinearGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
                <Ellipse x:Name="ellipse_Copy" Margin="4.861" RenderTransformOrigin="0.5,0.5">
                    <Ellipse.Fill>
                        <RadialGradientBrush>
                            <GradientStop Color="#FFC3C3C3" Offset="0"/>
                            <GradientStop Color="Black" Offset="1"/>
                            <GradientStop Color="#FFC3C3C3" Offset="0.9"/>
                        </RadialGradientBrush>
                    </Ellipse.Fill>
                    <Ellipse.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="-73.856"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Ellipse.RenderTransform>
                </Ellipse>
                <Ellipse x:Name="ellipse" Margin="4.861" RenderTransformOrigin="0.5,0.5">
                    <Ellipse.Fill>
                        <RadialGradientBrush>
                            <GradientStop Color="#FF23FF00" Offset="0"/>
                            <GradientStop Color="#FF23FF00" Offset="0.9"/>
                            <GradientStop Color="Black" Offset="1"/>
                        </RadialGradientBrush>
                    </Ellipse.Fill>
                    <Ellipse.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="-73.856"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Ellipse.RenderTransform>
                </Ellipse>
            </Grid>
        </Viewbox>
    </Grid>
</Window>


点击阅读本文所属分类的更多文章: 项目实战 。和高手一起交流:346717337
友荐云推荐

未注明转发、原文均为本站原创。分享本文请注明 原文链接

给您更多信息和帮助

在这里您可以找到更多:

技术交流群:346717337 Jquery插件交流

投稿:suchso@vip.qq.com

承接:企业网站门户/微网站/微商城/CMS系统/微信公众号运营/业务咨询

抢天猫双11红包
推荐使用阿里云服务器
echarts教程系列
本月最热文章

微信扫一扫,徜徉悠嘻网,您的休闲乐园

微信公众号:快乐每一天

随机文章
标签

技术交流群:346717337

投稿:suchso@vip.qq.com

专业专注:企业网站门户/微网站/微商城/CMS系统/微信公众号运营/付费问题咨询