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
[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
繼承
Condition
屬性
實作

範例

下列範例包含兩個 MultiTriggers。The 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>

如需 MultiDataTrigger中使用之條件的範例,請參閱 Binding 屬性。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()

傳回代表目前物件的字串。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.

適用於