TextBlock.FontWeight 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 bobot font tingkat atas untuk TextBlock.
public:
property System::Windows::FontWeight FontWeight { System::Windows::FontWeight get(); void set(System::Windows::FontWeight value); };
public System.Windows.FontWeight FontWeight { get; set; }
member this.FontWeight : System.Windows.FontWeight with get, set
Public Property FontWeight As FontWeight
Nilai Properti
Anggota kelas yang FontWeights menentukan bobot font yang diinginkan. Default ditentukan oleh MessageFontWeight nilai .
Contoh
Contoh berikut menunjukkan cara mengatur FontWeight atribut TextBlock elemen.
<TextBlock
Name="textBlock"
Background="AntiqueWhite"
Foreground="Navy"
FontFamily="Century Gothic"
FontSize="12"
FontStretch="UltraExpanded"
FontStyle="Italic"
FontWeight="UltraBold"
LineHeight="Auto"
Padding="5,10,5,10"
TextAlignment="Center"
TextWrapping="Wrap"
Typography.NumeralStyle="OldStyle"
Typography.SlashedZero="True"
>
<Run Background="LightGreen">Text run 1.</Run>
<LineBreak/><Run Background="LightBlue">Text run 2.</Run>
<LineBreak/><Run Background="LightYellow">Text run 3.</Run>
</TextBlock>
Contoh berikut menunjukkan cara mengatur properti FontWeight secara terprogram.
TextBlock textBlock = new TextBlock(new Run("A bit of text content..."));
textBlock.Background = Brushes.AntiqueWhite;
textBlock.Foreground = Brushes.Navy;
textBlock.FontFamily = new FontFamily("Century Gothic");
textBlock.FontSize = 12;
textBlock.FontStretch = FontStretches.UltraExpanded;
textBlock.FontStyle = FontStyles.Italic;
textBlock.FontWeight = FontWeights.UltraBold;
textBlock.LineHeight = Double.NaN;
textBlock.Padding = new Thickness(5, 10, 5, 10);
textBlock.TextAlignment = TextAlignment.Center;
textBlock.TextWrapping = TextWrapping.Wrap;
textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle;
textBlock.Typography.SlashedZero = true;
Dim textBlock As New TextBlock(New Run("A bit of text content..."))
textBlock.Background = Brushes.AntiqueWhite
textBlock.Foreground = Brushes.Navy
textBlock.FontFamily = New FontFamily("Century Gothic")
textBlock.FontSize = 12
textBlock.FontStretch = FontStretches.UltraExpanded
textBlock.FontStyle = FontStyles.Italic
textBlock.FontWeight = FontWeights.UltraBold
textBlock.LineHeight = Double.NaN
textBlock.Padding = New Thickness(5, 10, 5, 10)
textBlock.TextAlignment = TextAlignment.Center
textBlock.TextWrapping = TextWrapping.Wrap
textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle
textBlock.Typography.SlashedZero = True
Keterangan
Pengaturan apa pun FontWeight pada elemen turunan mengambil alih pengaturan tingkat atas ini.
Untuk daftar nilai bobot font yang valid, lihat FontWeights kelas .
Properti dependensi ini juga memiliki penggunaan properti terlampir. Dalam XAML, penggunaannya adalah <object TextBlock.FontWeight="value".../>, di mana objek adalah elemen objek (biasanya elemen alur) yang terkandung dalam TextBlock, dan nilai adalah salah satu nilai format string dari properti FontWeights kelas. Dalam kode, penggunaan properti terlampir didukung oleh GetFontWeight dan SetFontWeight. Penggunaan properti terlampir tidak umum, karena sebagian besar elemen yang dapat dimuat dalam TextBlock mendukung properti yang tidak terpasang FontWeight analog, yang digunakan untuk penyajian TextBlock .
Informasi Properti Dependensi
| Item | Nilai |
|---|---|
| Bidang pengidentifikasi | FontWeightProperty |
Properti metadata diatur ke true |
AffectsMeasure, , AffectsRenderInherits |