0

Considering following example (taken from MSDN sample)

<Style TargetType="Rectangle">
  <Style.Triggers>
    <EventTrigger RoutedEvent="MouseEnter">
        <BeginStoryboard>
            <Storyboard>
              <DoubleAnimation To="300" Duration="0:0:1.5" 
                AccelerationRatio="0.10" DecelerationRatio="0.25" 
                Storyboard.TargetProperty="(Canvas.Width)" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
    <EventTrigger RoutedEvent="MouseLeave">
        <BeginStoryboard>
            <Storyboard>
              <DoubleAnimation Duration="0:0:1.5" 
                AccelerationRatio="0.10" DecelerationRatio="0.25" 
                Storyboard.TargetProperty="(Canvas.Width)" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
  </Style.Triggers>
</Style>

There are 2 animiations, one for MouseEnter event, and another one for Mouse leave event.

Note that In the animation of Mouse Leave event, only Duration is specified. No From/To.By is specified. The remark section of DoubleAnimation specified either of From/To/By must be specified. My question is how this animation is working? Is it considering original value of rectangle as To value for the animation.

4

1 回答 1

1

它通过转换回默认值来工作。您引用的表格仅指定使用 from/to/by 的各种组合时的行为。

每个故事板都是独立的,因此他们不会跟踪其他故事板所做的事情,因此第一个故事板转换为定义的宽度,第二个故事板将其转换回原始值。

于 2013-05-29T03:12:57.993 回答