Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Trigger.Value Property

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

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
[TypeConverterAttribute(typeof(SetterTriggerConditionValueConverter))]
public Object Value { get; set; }
<object>
  <object.Value>
    Value
  </object.Value>
</object>

Property Value

Type: System.Object
The default value is null. See also the Exceptions section.

ExceptionCondition
ArgumentException

Only load-time MarkupExtensions are supported.

ArgumentException

Expressions such as bindings are not supported.

InvalidOperationException

After a Trigger is in use, it cannot be modified.

This value is compared with the property value returned by the Property property of the Trigger. The comparison that is performed is a reference quality check. If the two values are equal, then the associated Setters apply the specified property values.

Note that you must specify both the Property and Value properties on a Trigger for the trigger to be meaningful. Therefore, if one or both of the properties are not specified, then an exception is thrown.

The following example 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>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft