Condition Condition Condition Condition Class

定義

表示 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
[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
繼承
ConditionConditionConditionCondition
屬性
實作

範例

下列範例包含兩個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屬性MultiDataTriggerSee the Binding property for examples of conditions used in a MultiDataTrigger.

備註

MultiTriggerMultiDataTrigger可讓您根據一組條件來設定屬性值。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:

請注意MultiTrigger, 如果Condition適用于, 則Property必須設定Value和屬性。Note that if the Condition is for a MultiTrigger, the Property and Value properties must be set. 若為Value Binding , 則必須設定和屬性。 MultiDataTriggerIf it is for a MultiDataTrigger, the Binding and Value properties must be set.

建構函式

Condition() Condition() Condition() Condition()

初始化 Condition 類別的新執行個體。Initializes a new instance of the Condition class.

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

初始化 Condition 類別的新執行個體。Initializes a new instance of the Condition class.

Condition(DependencyProperty, Object) Condition(DependencyProperty, Object) Condition(DependencyProperty, Object) 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(DependencyProperty, Object, String) Condition(DependencyProperty, Object, String) 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 Binding Binding Binding

取得或設定指定條件屬性的繫結。Gets or sets the binding that specifies the property of the condition. 這只適用於 MultiDataTrigger 物件。This is only applicable to MultiDataTrigger objects.

Property Property Property Property

取得或設定條件的屬性。Gets or sets the property of the condition. 其僅適用於 MultiTrigger 物件。This is only applicable to MultiTrigger objects.

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

取得或設定條件的值。Gets or sets the value of the condition.

方法

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()

取得目前執行個體的 TypeGets the Type of the current instance.

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

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

處理標記延伸對 Condition 物件的屬性提供值的情況。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)

處理類型轉換子對 Condition 物件的屬性提供值的情況。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)

明確介面實作

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.

適用於