Condition Condition Condition 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 : System::ComponentModel::ISupportInitialize
[System.Windows.Markup.XamlSetMarkupExtension("ReceiveMarkupExtension")]
[System.Windows.Markup.XamlSetTypeConverter("ReceiveTypeConverter")]
public sealed class Condition : System.ComponentModel.ISupportInitialize
type Condition = class
    interface ISupportInitialize
Public NotInheritable Class Condition
Implements ISupportInitialize
Inheritance
ConditionConditionConditionCondition
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() Condition() Condition() Condition()

Initializes a new instance of the Condition class.

Condition(BindingBase, Object) Condition(BindingBase, Object) Condition(BindingBase, Object) Condition(BindingBase, Object)

Initializes a new instance of the Condition class.

Condition(DependencyProperty, Object) Condition(DependencyProperty, Object) Condition(DependencyProperty, Object) Condition(DependencyProperty, Object)

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

Condition(DependencyProperty, Object, String) Condition(DependencyProperty, Object, String) Condition(DependencyProperty, Object, String) Condition(DependencyProperty, Object, String)

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

Properties

Binding Binding Binding Binding

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

Property Property Property Property

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

SourceName SourceName SourceName 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 Value Value Value

Gets or sets the value of the condition.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs) ReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs) ReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs) ReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs)

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

ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs) ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs) ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs) ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs)

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

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

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.

Applies to