Condition Class
TOC
Collapse the table of content
Expand the table of content

Condition Class

 

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

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

System::Object
  System.Windows::Condition

[XamlSetMarkupExtensionAttribute("ReceiveMarkupExtension")]
[XamlSetTypeConverterAttribute("ReceiveTypeConverter")]
public ref class Condition sealed : ISupportInitialize

NameDescription
System_CAPS_pubmethodCondition()

Initializes a new instance of the Condition class.

System_CAPS_pubmethodCondition(BindingBase^, Object^)

Initializes a new instance of the Condition class.

System_CAPS_pubmethodCondition(DependencyProperty^, Object^)

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

System_CAPS_pubmethodCondition(DependencyProperty^, Object^, String^)

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

NameDescription
System_CAPS_pubpropertyBinding

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

System_CAPS_pubpropertyProperty

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

System_CAPS_pubpropertySourceName

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.

System_CAPS_pubpropertyValue

Gets or sets the value of the condition.

NameDescription
System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticReceiveMarkupExtension(Object^, XamlSetMarkupExtensionEventArgs^)

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

System_CAPS_pubmethodSystem_CAPS_staticReceiveTypeConverter(Object^, XamlSetTypeConverterEventArgs^)

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

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISupportInitialize::BeginInit()

This API supports the product infrastructure and is not intended to be used directly from your code. Signals the object that initialization is starting.

System_CAPS_pubinterfaceSystem_CAPS_privmethodISupportInitialize::EndInit()

This API supports the product infrastructure and is not intended to be used directly from your code. Signals the object that initialization is complete.

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:

  • For each Condition, you can only set either the Property property or the Binding property. If both properties are set, an exception is thrown.

  • If the Condition is for a MultiTrigger, the Property property cannot be null.

  • If the Condition is for a MultiDataTrigger, the Binding property cannot be null.

  • An exception is thrown if the specified Value is not valid for the type of the specified Property.

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.

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.

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft