Trigger Trigger Trigger Trigger Class
Represents a trigger that applies property values or performs actions conditionally.
public ref class Trigger : System::Windows::TriggerBase, System::ComponentModel::ISupportInitialize, System::Windows::Markup::IAddChild
[System.Windows.Markup.ContentProperty("Setters")] [System.Windows.Markup.XamlSetTypeConverter("ReceiveTypeConverter")] public class Trigger : System.Windows.TriggerBase, System.ComponentModel.ISupportInitialize, System.Windows.Markup.IAddChild
type Trigger = class inherit TriggerBase interface IAddChild interface ISupportInitialize
Public Class Trigger Inherits TriggerBase Implements IAddChild, ISupportInitialize
<Style x:Key="Triggers" TargetType="Button"> <Style.Triggers> <Trigger Property="IsPressed" Value="true"> <Setter Property = "Foreground" Value="Green"/> </Trigger> </Style.Triggers> </Style>
WPF defines properties that correspond to end-user actions, such as the IsMouseOver property that is set to
true when the user hovers the cursor over a UIElement or the corresponding IsMouseOver 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 IsPressed on Button and IsSelected on ListBoxItem. The Property of interest must be a dependency property.
The Setters 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 Style.Setters 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.
|Trigger() Trigger() Trigger() Trigger()||
Initializes a new instance of the Trigger class.
|DependencyObjectType DependencyObjectType DependencyObjectType DependencyObjectType||
Gets the DependencyObjectType that wraps the CLR type of this instance.(Inherited from DependencyObject)
|Dispatcher Dispatcher Dispatcher Dispatcher||DispatcherObject)|
|EnterActions EnterActions EnterActions EnterActions||TriggerBase)|
|ExitActions ExitActions ExitActions ExitActions||TriggerBase)|
|IsSealed IsSealed IsSealed IsSealed||
Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject)
|Property Property Property Property||
Gets or sets the property that returns the value that is compared with the Value property of the trigger. The comparison is a reference equality check.
|Setters Setters Setters Setters||
Gets a collection of Setter objects, which describe the property values to apply when the specified condition has been met.
|SourceName SourceName SourceName SourceName||
Gets or sets the name of the object with the property that causes the associated setters to be applied.
|Value Value Value Value||
Gets or sets the value to be compared with the property value of the element. The comparison is a reference equality check.
Explicit Interface Implementations
|IAddChild.AddChild(Object) IAddChild.AddChild(Object) IAddChild.AddChild(Object) IAddChild.AddChild(Object)||
Adds a child object.
|IAddChild.AddText(String) IAddChild.AddText(String) IAddChild.AddText(String) IAddChild.AddText(String)||
Adds the text content of a node to the object.
|ISupportInitialize.BeginInit() ISupportInitialize.BeginInit() ISupportInitialize.BeginInit() ISupportInitialize.BeginInit()||
Signals the object that initialization is starting.
|ISupportInitialize.EndInit() ISupportInitialize.EndInit() ISupportInitialize.EndInit() ISupportInitialize.EndInit()||
Signals the object that initialization is complete.