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

属性值

默认值为空集合。

示例

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

注意

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

XAML 属性元素用法

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

XAML 值

OneOrMoreTriggerActions
一个或多个 TriggerAction 对象。

适用于

另请参阅