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 ,以隱含方式將它新增至 物件的 。 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 物件,以隱含方式將它新增至 TriggerActionCollection 物件的 EventTrigger

注意

此屬性只能在 Extensible Application Markup Language (XAML) 中設定,方法是透過顯示的集合語法,或是存取集合物件,以及使用其各種方法,例如 Add。 存取集合物件本身的屬性是唯讀的,集合本身是可讀寫的。

XAML 屬性項目用法

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

XAML 值

OneOrMoreTriggerActions
一或多個 TriggerAction 物件。

適用於

另請參閱