共用方式為


Trigger.Property 屬性

定義

取得或設定回傳與觸發條件屬性比較 Value 的值的屬性。 比較是參考資料的平等性檢查。

public:
 property System::Windows::DependencyProperty ^ Property { System::Windows::DependencyProperty ^ get(); void set(System::Windows::DependencyProperty ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Modifiability=System.Windows.Modifiability.Unmodifiable, Readability=System.Windows.Readability.Unreadable)]
[System.Windows.Markup.Ambient]
public System.Windows.DependencyProperty Property { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Modifiability=System.Windows.Modifiability.Unmodifiable, Readability=System.Windows.Readability.Unreadable)>]
[<System.Windows.Markup.Ambient>]
member this.Property : System.Windows.DependencyProperty with get, set
Public Property Property As DependencyProperty

屬性值

DependencyProperty A 回傳該元素的屬性值。 預設值為 null

屬性

例外狀況

A Style 不能包含指涉該Style性質的 aTrigger

一旦 a Trigger 在使用中,就無法再修改。

範例

以下範例包含一個觸發器,當屬性IsPressedtrue時,會改變Foreground按鈕的屬性。 由於 TargetTypeStyle 被設定為 Button,因此不需要用類別名稱來限定 Property 屬性,例如 Property="IsPressed"

<Style x:Key="Triggers" TargetType="Button">
    <Style.Triggers>
    <Trigger Property="IsPressed" Value="true">
        <Setter Property = "Foreground" Value="Green"/>
    </Trigger>
    </Style.Triggers>
</Style>

備註

此屬性回傳的值會與該 Value 屬性指定的值進行比較。 所進行的比較是參考資料的平等性檢查。 若兩個值相符,則對應 Setter的 s 會套用指定的屬性值。

如果包含此觸發器的樣式或範本沒有設定該TargetType屬性,請使用ClassName.PropertyName語法來限定你指定的屬性。

請注意,觸發條件必須同時指定 Property a Trigger 上的屬性Value和屬性,觸發才有意義。 若其中一項或兩種屬性未被設定,則會拋出例外。

適用於

另請參閱