Share via


EventTrigger.Actions 属性

定义

获取事件发生时要应用的操作的集合。

public:
 property System::Windows::TriggerActionCollection ^ Actions { System::Windows::TriggerActionCollection ^ get(); };
public System.Windows.TriggerActionCollection Actions { get; }
member this.Actions : System.Windows.TriggerActionCollection
Public ReadOnly Property Actions As TriggerActionCollection

属性值

默认值为空集合。

示例

此示例介绍如何使用样式中的事件触发器对 和 MouseLeave 事件FrameworkElement进行动画处理MouseEnter。 如上所述,向 对象添加TriggerActionEventTrigger级会隐式地将其添加到 对象的 。TriggerActionCollectionEventTrigger 因此,在此示例中, <EventTrigger.Actions> 是隐式的。

<Style TargetType="Rectangle">
  <Setter Property="Width" Value="50" />
  <Setter Property="Height" Value="50" />
  <Setter Property="Margin" Value="20" />
  <Setter Property="HorizontalAlignment" Value="Left" />
  <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>

注解

与 不同 TriggerEventTrigger 没有状态终止的概念,因此一旦引发事件的条件不再成立,操作将不会撤消。

TriggerAction向 对象添加子EventTrigger级会将其隐式添加到 对象的 。TriggerActionCollectionEventTrigger

注意

只能通过显示的集合语法或访问集合对象并使用其各种方法(例如 Add)在可扩展应用程序标记语言 (XAML) 中设置此属性。 用于访问集合对象本身的属性是只读的,集合本身是读写的。

XAML 属性元素用法

<object>
  <object.Actions>
    OneOrMoreTriggerActions
  </object.Actions>
</object>

XAML 值

OneOrMoreTriggerActions 一个或多个 TriggerAction 对象。

适用于