Setter.Property Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur properti tempat Value akan diterapkan.
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
Nilai Properti
A DependencyProperty yang Value akan diterapkan. Nilai default-nya adalah null.
- Atribut
Pengecualian
Properti Property tidak boleh null.
Properti yang ditentukan Property tidak dapat bersifat baca-saja.
Contoh
Contoh berikut mendefinisikan gaya yang akan diterapkan ke setiap TextBlock elemen.
<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>
Contoh berikut menunjukkan deklarasi gaya yang akan memengaruhi Background properti .Control Perhatikan bahwa nama properti dalam contoh ini memenuhi syarat dengan nama kelas (Control) karena Style tidak menentukan TargetType.
<Style x:Key="Style1">
<Setter Property="Control.Background" Value="Yellow"/>
</Style>
Keterangan
Perhatikan bahwa Anda harus menentukan Property properti dan Value pada Setter atau pengecualian akan dilemparkan.