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,傳回項目的屬性值。 預設值是 null

屬性

例外狀況

Style 不能包含參照 Trigger 屬性的 Style

Trigger 變成使用中狀態之後,便無法對其進行修改。

範例

下列範例包含觸發程式,當 屬性為 trueIsPressed ,會變更 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 會套用指定的屬性值。

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

請注意,您必須在 上 Trigger 指定 PropertyValue 屬性,讓觸發程式有意義。 如果未設定其中一或兩個屬性,則會擲回例外狀況。

適用於

另請參閱