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

属性值

默认值为空集合。

示例

本示例介绍如何使用样式中的事件触发器对事件和MouseEnter事件进行MouseLeave动画处理FrameworkElement。 如上所述,向 TriggerAction 对象添加子级 EventTrigger 会隐式将其添加到 TriggerActionCollection 对象中 EventTrigger 。 因此,在此示例中, <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 对象的子级。

注释

此属性只能通过显示的集合语法在 Extensible Application Markup Language (XAML)中设置,也可以通过访问集合对象并使用其各种方法(如 Add)进行设置。 访问集合对象本身的属性是只读的,集合本身是读写的。

XAML 属性元素用法

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

XAML 值

OneOrMoreTriggerActions 一个或多个 TriggerAction 对象。

适用于