Trigger Class
 

Represents a trigger that applies property values or performs actions conditionally.

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)


[ContentPropertyAttribute("Setters")]
[XamlSetTypeConverterAttribute("ReceiveTypeConverter")]
public class Trigger : TriggerBase, IAddChild, ISupportInitialize
[ContentPropertyAttribute("Setters")]
[XamlSetTypeConverterAttribute("ReceiveTypeConverter")]
public ref class Trigger : TriggerBase, IAddChild, ISupportInitialize
[<ContentPropertyAttribute("Setters")>]
[<XamlSetTypeConverterAttribute("ReceiveTypeConverter")>]
type Trigger = 
    class
        inherit TriggerBase
        interface IAddChild
        interface ISupportInitialize
    end
<ContentPropertyAttribute("Setters")>
<XamlSetTypeConverterAttribute("ReceiveTypeConverter")>
Public Class Trigger
	Inherits TriggerBase
	Implements IAddChild, ISupportInitialize
NameDescription
System_CAPS_pubmethod Trigger

Initializes a new instance of the Trigger class.

NameDescription
System_CAPS_pubproperty

Gets the DependencyObjectType that wraps the CLR type of this instance. (Inherited from DependencyObject.)

System_CAPS_pubproperty

Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)

System_CAPS_pubproperty

Gets a collection of TriggerAction objects to apply when the trigger object becomes active. This property does not apply to the EventTrigger class.(Inherited from TriggerBase.)

System_CAPS_pubproperty

Gets a collection of TriggerAction objects to apply when the trigger object becomes inactive. This property does not apply to the EventTrigger class.(Inherited from TriggerBase.)

System_CAPS_pubproperty

Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject.)

System_CAPS_pubproperty

Gets or sets the property that returns the value that is compared with the property of the trigger. The comparison is a reference equality check.

System_CAPS_pubproperty

Gets a collection of Setter objects, which describe the property values to apply when the specified condition has been met.

System_CAPS_pubproperty

Gets or sets the name of the object with the property that causes the associated setters to be applied.

System_CAPS_pubproperty

Gets or sets the value to be compared with the property value of the element. The comparison is a reference equality check.

NameDescription
System_CAPS_pubmethod CheckAccess

Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_pubmethod ClearValue

Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.)

System_CAPS_pubmethod ClearValue

Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.)

System_CAPS_pubmethod CoerceValue

Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.(Inherited from DependencyObject.)

System_CAPS_pubmethod Equals

Determines whether a provided DependencyObject is equivalent to the current DependencyObject.(Inherited from DependencyObject.)

System_CAPS_protmethod Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethod GetHashCode

Gets a hash code for this DependencyObject.(Inherited from DependencyObject.)

System_CAPS_pubmethod GetLocalValueEnumerator

Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod GetValue

Returns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.)

System_CAPS_pubmethod InvalidateProperty

Re-evaluates the effective value for the specified dependency property(Inherited from DependencyObject.)

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethod OnPropertyChanged

Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data. (Inherited from DependencyObject.)

System_CAPS_pubmethod ReadLocalValue

Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)

System_CAPS_pubmethod System_CAPS_static ReceiveTypeConverter

Handles cases where a type converter provides a value for a property of a Trigger object.

System_CAPS_pubmethod SetCurrentValue

Sets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)

System_CAPS_pubmethod SetValue

Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)

System_CAPS_pubmethod SetValue

Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.)

System_CAPS_protmethod ShouldSerializeProperty

Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.(Inherited from DependencyObject.)

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethod VerifyAccess

Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

NameDescription
System_CAPS_pubinterface System_CAPS_privmethod ISupportInitializeBeginInit

This API supports the product infrastructure and is not intended to be used directly from your code. Signals the object that initialization is starting.

System_CAPS_pubinterface System_CAPS_privmethod ISupportInitializeEndInit

This API supports the product infrastructure and is not intended to be used directly from your code. Signals the object that initialization is complete.

System_CAPS_pubinterface System_CAPS_privmethod IAddChildAddChild

Adds a child object.

System_CAPS_pubinterface System_CAPS_privmethod IAddChildAddText

Adds the text content of a node to the object.

WPF defines properties that correspond to end-user actions, such as the property that is set to true when the user hovers the cursor over a UIElement or the corresponding property of a ContentElement. Representing end-user actions in property values, along with the Trigger element, allows WPF styles to change property values based on those end-user actions, all from within markup.

The properties changed by triggers are automatically reset to their previous value when the triggered condition is no longer satisfied. Triggers are optimized for transient states which are expected to change and return to original state, such as on Button and on ListBoxItem. The of interest must be a dependency property.

Note that you must specify both the and properties on a Trigger for the trigger to be meaningful. If one or both of the properties are not set, an exception is thrown.

The property of a Trigger object can only consist of Setter objects. Adding a Setter child to a Trigger object implicitly adds it to the SetterBaseCollection for the Trigger object. EventSetter objects are not supported; only supports EventSetter objects.

There are other types of triggers. MultiTrigger allows you to apply changes based on the state of multiple properties. EventTrigger allows you to apply changes when an event occurs. DataTrigger and MultiDataTrigger are for data-bound properties.

The following example shows a named Style available to Button controls. The Style defines a Trigger element that changes the property of a button when the 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>
.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top