EventTrigger.Actions 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得事件發生時套用的行動集合。
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 和 MouseLeaveFrameworkElement事件。 如前所述,將子節點加入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>
備註
與 Trigger不同, EventTrigger 則沒有狀態終止的概念,因此當引發事件的條件不再成立時,該動作不會被撤銷。
將子節點加入TriggerActionEventTrigger物件隱含地加入TriggerActionCollection該物件的 。EventTrigger
Note
此屬性只能透過所示的集合語法,或透過存取集合物件並使用各種方法(如 Add)來設定。 存取集合物件本身的屬性是唯讀,集合本身是讀寫。
XAML 屬性元素使用方式
<object>
<object.Actions>
OneOrMoreTriggerActions
</object.Actions>
</object>
XAML 值
一或多觸發行動 一個或多個 TriggerAction 物件。