Rediger

Del via


Style.Triggers Property

Definition

Gets a collection of TriggerBase objects that apply property values based on specified conditions.

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 collection of TriggerBase objects. The default is an empty collection.

Examples

The following example shows a named Style available to Button controls. The Style defines a Trigger element that changes the Foreground property of a button when the IsPressed property is true.

<Style x:Key="Triggers" TargetType="Button">
    <Style.Triggers>
    <Trigger Property="IsPressed" Value="true">
        <Setter Property = "Foreground" Value="Green"/>
    </Trigger>
    </Style.Triggers>
</Style>

Remarks

The WPF styling and templating model enables you to specify triggers within your Style. Essentially, triggers are objects that enable you to apply changes when certain conditions (such as when a certain property value becomes true, or when an event occurs) are satisfied.

XAML Property Element Usage

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

XAML Values

oneOrMoreTriggers Zero or more object elements that are classes deriving from TriggerBase.

Applies to

See also