Condition 类

定义

表示 MultiTriggerMultiDataTrigger 的条件,它们两个将根据一组条件对属性值应用更改。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
public ref class Condition sealed
[System.Windows.Markup.XamlSetMarkupExtension("ReceiveMarkupExtension")]
[System.Windows.Markup.XamlSetTypeConverter("ReceiveTypeConverter")]
public sealed class Condition : System.ComponentModel.ISupportInitialize
public sealed class Condition
type Condition = class
    interface ISupportInitialize
type Condition = class
Public NotInheritable Class Condition
Implements ISupportInitialize
Public NotInheritable Class Condition
继承
Condition
属性
实现

示例

下面的示例包含两个 MultiTriggerThe following example contains two MultiTriggers. 如果HasItems属性为 False 且Width属性为Auto,则第一个设置MinWidth属性值。第二个是类似的,但适用于MinHeight属性。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>

请参阅 Binding 属性,了解 MultiDataTrigger中使用的条件的示例。See the Binding property for examples of conditions used in a MultiDataTrigger.

注解

MultiTriggers 和 MultiDataTrigger,你可以根据一组条件设置属性值。MultiTriggers and MultiDataTriggers allow you to set property values based on a set of conditions. 当元素或数据项的属性值与指定的 Value (引用相等性检查)匹配时,满足条件。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:

请注意,如果 Condition 用于 MultiTrigger,则必须设置 PropertyValue 属性。Note that if the Condition is for a MultiTrigger, the Property and Value properties must be set. 如果它用于 MultiDataTrigger,则必须设置 BindingValue 属性。If it is for a MultiDataTrigger, the Binding and Value properties must be set.

构造函数

Condition()

初始化 Condition 类的新实例。Initializes a new instance of the Condition class.

Condition(BindingBase, Object)

初始化 Condition 类的新实例。Initializes a new instance of the Condition class.

Condition(DependencyProperty, Object)

用指定的属性和值初始化 Condition 类的新实例。Initializes a new instance of the Condition class with the specified property and value. 此构造函数执行参数验证。This constructor performs parameter validation.

Condition(DependencyProperty, Object, String)

使用指定的属性、值和源对象的名称初始化 Condition 类的新实例。Initializes a new instance of the Condition class with the specified property, value, and the name of the source object.

属性

Binding

获取或设置指定条件的属性的绑定。Gets or sets the binding that specifies the property of the condition. 这只适用于 MultiDataTrigger 对象。This is only applicable to MultiDataTrigger objects.

Property

获取或设置条件的属性。Gets or sets the property of the condition. 它仅适用于 MultiTrigger 对象。This is only applicable to MultiTrigger objects.

SourceName

获取或设置对象的名称,该对象具有可应用关联的 setter 的属性。Gets or sets the name of the object with the property that causes the associated setters to be applied. 这只适用于 MultiTrigger 对象。This is only applicable to MultiTrigger objects.

Value

获取或设置条件的值。Gets or sets the value of the condition.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ReceiveMarkupExtension(Object, XamlSetMarkupExtensionEventArgs)

处理标记扩展为 Condition 对象的属性提供值的情况。Handles cases where a markup extension provides a value for a property of a Condition object.

ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs)

处理类型转换器为 Condition 对象的属性提供值的情况。Handles cases where a type converter provides a value for a property of on a Condition object.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

ISupportInitialize.BeginInit()

用信号通知对象初始化即将开始。Signals the object that initialization is starting.

ISupportInitialize.EndInit()

用信号通知对象初始化已完成。Signals the object that initialization is complete.

适用于