FrameworkElement.Triggers FrameworkElement.Triggers FrameworkElement.Triggers FrameworkElement.Triggers Property


取得直接在這個項目或子項目中建立的觸發程序集合。Gets the collection of triggers established directly on this element, or in child elements.

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


Trigger 物件的強類型集合。A strongly typed collection of Trigger objects.



此屬性只在設定Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)透過集合語法所示,或存取的集合物件,使用其不同的方法,例如 Add。This property can only be set in Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) through the collection syntax shown, or by accessing the collection object and using its various methods such as Add. 要存取的集合物件本身的屬性是唯讀,該集合本身是讀寫。The property to access the collection object itself is read-only, the collection itself is read-write. 屬性只存在於根項目;嘗試找到它,或將它設定其他位置,將會導致擲回例外狀況。The property only exists on root elements; attempting to find it or set it elsewhere will cause an exception to be thrown.

這個屬性不會啟用檢查觸發程序,這個項目上的使用中的樣式的一部分。This property does not enable you to examine triggers that exist as part of styles in use on this element. 此外,它只會報告解譯為常值加入至集合,在標記或程式碼中的觸發程序的集合。It only reports the collection of triggers that are literally added to the collection, either in markup or code. 項目通常不會有這類現有的預設值的項目 (透過範本執行個體);它是更常見會改為在樣式中建立的複合控制項所來自的觸發程序。Elements do not typically have such elements existing by default (through a template for instance); it is more common for triggers that come from control compositing to be established in styles instead.

就行為 (並嘗試建立的作用是來自哪個項目宣告Triggers集合),觸發條件和觸發程序的效果可能在這個項目上,或可能在其子項目邏輯樹狀結構中。In terms of behavior (and trying to establish which effect came from which element's declared Triggers collection), both the triggering condition and the trigger effect might be on this element, or might be on its child elements in the logical tree. 請注意,如果您使用存留期事件,例如Loaded若要取得此集合,子元素的觸發程序可能還無法完全載入,並會在執行階段會確實比較小的集合。Note that if you use lifetime events such as Loaded to get this collection, the child element's triggers might not yet be fully loaded, and the collection will be smaller than it would truly be at run time.

請注意,建立項目上的觸發程序的集合只支援EventTrigger,沒有屬性觸發程序 (Trigger)。Note that the collection of triggers established on an element only supports EventTrigger, not property triggers (Trigger). 如果您需要屬性觸發程序,您必須放在樣式或範本內,並再指派該樣式或範本的項目是直接透過Style屬性,或間接透過隱含樣式參考。If you require property triggers, you must place these within a style or template and then assign that style or template to the element either directly through the Style property, or indirectly through an implicit style reference.

XAML 屬性項目用法XAML Property Element Usage



一或多個定義EventTrigger項目。One or more defined EventTrigger elements. 每個這類觸發程序必須包含有效的分鏡腳本動作和參考。Each such trigger is expected to contain valid storyboard actions and references. 請注意,這個集合只能建立在頁面的根項目。Note that this collection can only be established on the root element of a page. 如需詳細資訊,請參閱分鏡腳本概觀For more information, see Storyboards Overview.