Edit

Share via


Condition Class

Definition

Represents a condition for the MultiTrigger and the MultiDataTrigger, which apply changes to property values based on a set of conditions.

public ref class Condition sealed
public ref class Condition sealed : System::ComponentModel::ISupportInitialize
public sealed class Condition
[System.Windows.Markup.XamlSetMarkupExtension("ReceiveMarkupExtension")]
[System.Windows.Markup.XamlSetTypeConverter("ReceiveTypeConverter")]
public sealed class Condition : System.ComponentModel.ISupportInitialize
type Condition = class
[<System.Windows.Markup.XamlSetMarkupExtension("ReceiveMarkupExtension")>]
[<System.Windows.Markup.XamlSetTypeConverter("ReceiveTypeConverter")>]
type Condition = class
    interface ISupportInitialize
Public NotInheritable Class Condition
Public NotInheritable Class Condition
Implements ISupportInitialize
Inheritance
Condition
Attributes
Implements

Examples

The following example contains two MultiTriggers. The first sets the MinWidth property value when the HasItems property is false and the Width property is Auto. The second one is similar but is for the MinHeight property.

<Style.Triggers>
  <Trigger Property="IsEnabled" Value="false">
    <Setter Property="Background" Value="#EEEEEE" />
  </Trigger>

  <MultiTrigger>
    <MultiTrigger.Conditions>
      <Condition Property="HasItems" Value="false" />
      <Condition Property="Width" Value="Auto" />
    </MultiTrigger.Conditions>
    <Setter Property="MinWidth" Value="120"/>
  </MultiTrigger>

  <MultiTrigger>
    <MultiTrigger.Conditions>
      <Condition Property="HasItems" Value="false" />
      <Condition Property="Height" Value="Auto" />
    </MultiTrigger.Conditions>
    <Setter Property="MinHeight" Value="95"/>
  </MultiTrigger>
</Style.Triggers>

See the Binding property for examples of conditions used in a MultiDataTrigger.

Remarks

MultiTriggers and MultiDataTriggers allow you to set property values based on a set of conditions. A condition is satisfied when the property value of the element or data item matches the specified Value (reference equality check). If all specified conditions are satisfied, then the trigger is applied.

The following is a list of cases that will cause an exception:

Note that if the Condition is for a MultiTrigger, the Property and Value properties must be set. If it is for a MultiDataTrigger, the Binding and Value properties must be set.

Constructors

Condition()

Initializes a new instance of the Condition class.

Condition(BindingBase, Object)

Initializes a new instance of the Condition class.

Condition(DependencyProperty, Object, String)

Initializes a new instance of the Condition class with the specified property, value, and the name of the source object.

Condition(DependencyProperty, Object)

Initializes a new instance of the Condition class with the specified property and value. This constructor performs parameter validation.

Properties

Binding

Gets or sets the binding that specifies the property of the condition. This is only applicable to MultiDataTrigger objects.

Property

Gets or sets the property of the condition. This is only applicable to MultiTrigger objects.

SourceName

Gets or sets the name of the object with the property that causes the associated setters to be applied. This is only applicable to MultiTrigger objects.

Value

Gets or sets the value of the condition.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs)

Handles cases where a markup extension provides a value for a property of a Condition object.

ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs)

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

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ISupportInitialize.BeginInit()

Signals the object that initialization is starting.

ISupportInitialize.EndInit()

Signals the object that initialization is complete.

Applies to