Bewerken

Share via


FrameworkElement.Triggers Property

Definition

Gets the collection of triggers established directly on this element, or in child elements.

public:
 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

Property Value

A strongly typed collection of Trigger objects.

Remarks

Note

This property can only be set in 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.

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. 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.

Note that the collection of triggers established on an element only supports EventTrigger, not property triggers (Trigger). 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 Property Element Usage

<object>  
  <object.Triggers>  
    oneOrMoreTriggers  
  </object.Triggers>  
</object>  

XAML Values

oneOrMoreTriggers
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.

Applies to

See also