Setter Setter Setter Setter Class

定義

表示套用屬性值的 setter。Represents a setter that applies a property value.

public ref class Setter : System::Windows::SetterBase, System::ComponentModel::ISupportInitialize
[System.Windows.Markup.XamlSetMarkupExtension("ReceiveMarkupExtension")]
[System.Windows.Markup.XamlSetTypeConverter("ReceiveTypeConverter")]
public class Setter : System.Windows.SetterBase, System.ComponentModel.ISupportInitialize
type Setter = class
    inherit SetterBase
    interface ISupportInitialize
Public Class Setter
Inherits SetterBase
Implements ISupportInitialize
繼承
屬性
實作

範例

下列範例會定義Style將套用至每個TextBlock元素的。The following example defines a Style that will be applied to every TextBlock element. Style會將值套用TextBlock至數個使用Setters 的屬性。This Style applies values to several TextBlock properties with the use of Setters.

<Style TargetType="{x:Type TextBlock}">
  <Setter Property="FontFamily" Value="Segoe Black" />
  <Setter Property="HorizontalAlignment" Value="Center" />
  <Setter Property="FontSize" Value="12pt" />
  <Setter Property="Foreground" Value="#777777" />
</Style>

下列範例會顯示名Style為的Button控制項可用的。The following example shows a named Style available to Button controls. Style Foreground定義當屬性IsPressed為時, 會變更true按鈕屬性的元素。TriggerThe Style defines a Trigger element that changes the Foreground property of a button when the IsPressed property is true.

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

備註

Styles 和不同類型的觸發程式 (繼承自TriggerBase的類別) 會使用Setter來套用屬性值。Styles and the different types of triggers (classes that inherit from TriggerBase) use Setters to apply property values.

請注意, 您必須在上Property Setter同時Value指定和屬性, setter 才有意義。Note that you must specify both the Property and Value properties on a Setter for the setter to be meaningful. 如果未設定其中一個或兩個屬性, 則會擲回例外狀況。If one or both properties are not set, an exception will be thrown.

建構函式

Setter() Setter() Setter() Setter()

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

Setter(DependencyProperty, Object) Setter(DependencyProperty, Object) Setter(DependencyProperty, Object) Setter(DependencyProperty, Object)

使用指定的屬性和值,初始化 Setter 類別的新執行個體。Initializes a new instance of the Setter class with the specified property and value.

Setter(DependencyProperty, Object, String) Setter(DependencyProperty, Object, String) Setter(DependencyProperty, Object, String) Setter(DependencyProperty, Object, String)

使用指定的屬性、值和目標名稱,初始化 Setter 類別的新執行個體。Initializes a new instance of the Setter class with the specified property, value, and target name.

屬性

IsSealed IsSealed IsSealed IsSealed

取得值,這個值表示這個物件是否處於不變的狀態。Gets a value that indicates whether this object is in an immutable state.

(Inherited from SetterBase)
Property Property Property Property

取得或設定將套用 Value 的屬性。Gets or sets the property to which the Value will be applied.

TargetName TargetName TargetName TargetName

取得或設定這個 Setter 適用的物件名稱。Gets or sets the name of the object this Setter is intended for.

Value Value Value Value

取得或設定值,這個值要套用到這個 Setter 所指定的屬性。Gets or sets the value to apply to the property that is specified by this Setter.

方法

CheckSealed() CheckSealed() CheckSealed() CheckSealed()

檢查這個物件是否為唯讀而無法變更。Checks whether this object is read-only and cannot be changed.

(Inherited from SetterBase)
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)

處理標記延伸對 Setter 物件的屬性提供值的情況。Handles cases where a markup extension provides a value for a property of Setter object.

ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs) ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs) ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs) ReceiveTypeConverter(Object, XamlSetTypeConverterEventArgs)

處理型別轉換子對 Setter 物件的屬性提供值的情況。Handles cases where a type converter provides a value for a property of a Setter 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.

適用於

另請參閱