Επεξεργασία

Κοινή χρήση μέσω


Trigger.Property Property

Definition

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.

public:
 property System::Windows::DependencyProperty ^ Property { System::Windows::DependencyProperty ^ get(); void set(System::Windows::DependencyProperty ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Modifiability=System.Windows.Modifiability.Unmodifiable, Readability=System.Windows.Readability.Unreadable)]
[System.Windows.Markup.Ambient]
public System.Windows.DependencyProperty Property { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Modifiability=System.Windows.Modifiability.Unmodifiable, Readability=System.Windows.Readability.Unreadable)>]
[<System.Windows.Markup.Ambient>]
member this.Property : System.Windows.DependencyProperty with get, set
Public Property Property As DependencyProperty

Property Value

A DependencyProperty that returns the property value of the element. The default value is null.

Attributes

Exceptions

A Style cannot contain a Trigger that refers to the Style property.

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

Examples

The following example contains a trigger that changes the Foreground property of a button when the IsPressed property is true. Because the TargetType of the Style is set to Button, there's no need to qualify the Property properties, for example, Property="IsPressed", with the class name.

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

Remarks

The value returned by this property is compared with the value specified by the Value property. The comparison that is performed is a reference equality check. If the two values match, then the associated Setters apply the specified property values.

Use the ClassName.PropertyName syntax to qualify the property you are specifying if the style or template that contains this trigger does not have the TargetType property set.

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

Applies to

See also