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

定义

获取直接在此元素上或在子元素中建立的触发器的集合。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

属性值

Trigger 对象的强类型集合。A strongly typed collection of Trigger objects.

注解

备注

此属性只能可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML)通过显示的集合语法来设置, 或者通过访问集合对象并使用它的各种方法 (如 Add) 来设置。This property can only be set in 可扩展应用程序标记语言 (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

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

XAML 值XAML Values

oneOrMoreTriggersoneOrMoreTriggers
一个或多个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.

适用于

另请参阅