首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WPF c# XAML ismouseover动画

WPF c# XAML ismouseover动画
EN

Stack Overflow用户
提问于 2017-04-02 17:52:46
回答 1查看 100关注 0票数 1

在我的项目中,当程序启动多边形在设定的路径上移动时,我应该改变什么来停止多边形的移动,当鼠标光标在它上面时(当鼠标光标离开多边形时,多边形必须继续它的移动)

代码语言:javascript
复制
<Window x:Class="aqua3.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:aqua3"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <PathGeometry x:Key="pathg">
        <PathFigure IsClosed="True">
            <PolyLineSegment Points="0,0 200,0 200,80 0,80" />
        </PathFigure>
    </PathGeometry>
</Window.Resources>
<Grid Background="LightBlue">
    <Canvas Margin="10" Background="LightBlue">
        <Path Stroke="Red" Data="{StaticResource pathg}" Canvas.Top="10" Canvas.Left="10" />
        <Polygon Name="polygon1" Stroke="Yellow" Fill="Yellow"  Points="100,150 120,140 120,120 165,150 120,180 120,160 ">
            <Polygon.Triggers>
                <EventTrigger RoutedEvent="Window.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingPath Storyboard.TargetProperty="(Canvas.Top)"
                                   Duration="0:0:15" RepeatBehavior="Forever"
                                   PathGeometry="{StaticResource pathg}" Source="Y" >
                            </DoubleAnimationUsingPath>
                            <DoubleAnimationUsingPath Storyboard.TargetProperty="(Canvas.Left)"
                                   Duration="0:0:15" RepeatBehavior="Forever"
                                   PathGeometry="{StaticResource pathg}" Source="X" >
                            </DoubleAnimationUsingPath>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Polygon.Triggers>
        </Polygon>
    </Canvas>
</Grid>

EN

回答 1

Stack Overflow用户

发布于 2017-04-02 19:32:45

  1. 为您的BeginStoryboard指定一个名称

  • 要暂停,请添加以下内容

  • 要继续,请添加此
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43166977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档