Trigger.Setters 属性

定义

获取 Setter 对象的集合,这些对象描述当满足指定条件时要应用的属性值。Gets a collection of Setter objects, which describe the property values to apply when the specified condition has been met.

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

属性值

SetterBaseCollection

默认值是 nullThe default value is null.

示例

如上所述,将 Setter 子对象添加到 Trigger 对象会将其隐式添加到 SetterBaseCollection 对象的 TriggerAs mentioned above, adding a Setter child to a Trigger object implicitly adds it to the SetterBaseCollection for the Trigger object. 在下面的示例中, <Trigger.Setters> 是隐式的。In the following example, <Trigger.Setters> is implicit.

    <ControlTemplate.Triggers>
      <Trigger Property="IsSelected" Value="True">
<Trigger.Setters>
           <Setter Property="Opacity" Value="1.0" />
</Trigger.Setters>
      </Trigger>
    </ControlTemplate.Triggers>

注解

XAML 属性元素用法XAML Property Element Usage

<object>  
  <object.Setters>  
    ZeroOrMoreSetters  
  </object.Setters>  
</object>  

XAML 值XAML Values

ZeroOrMoreSettersZeroOrMoreSetters
零个或多个 Setter 对象。Zero or more Setter objects. 这不支持 EventSetter 对象。This does not support EventSetter object.

Trigger Setter 当元素满足指定条件时,可以使用来应用属性值。A Trigger allows you to use Setters to apply property values when the element meets a specified condition. 例如,你可能想要在元素处于焦点时更改其背景色。For example, you may want to change the background color of an element when it is in focus.

如果多次设置同一属性,则将应用最后一个属性值。If the same property is set more than once, the last property value will be applied.

Setters对象的属性 Trigger 只能包含 Setter 对象。The Setters property of a Trigger object can only consist of Setter objects. Setter 子对象添加到 Trigger 对象会将该子级隐式添加到 SetterBaseCollection 对象的 TriggerAdding a Setter child to a Trigger object implicitly adds it to the SetterBaseCollection for the Trigger object. EventSetter 对象不受支持;仅 Style.Setters 支持 EventSetter 对象。EventSetter objects are not supported; only Style.Setters supports EventSetter objects.

适用于