TextElement.FontStyle 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 gaya font untuk konten elemen.
public:
property System::Windows::FontStyle FontStyle { System::Windows::FontStyle get(); void set(System::Windows::FontStyle value); };
public System.Windows.FontStyle FontStyle { get; set; }
member this.FontStyle : System.Windows.FontStyle with get, set
Public Property FontStyle As FontStyle
Nilai Properti
Gaya font yang diinginkan. Default ditentukan oleh MessageFontStyle nilai .
Contoh
Contoh berikut menunjukkan cara mengatur atribut FontStyle, menggunakan Paragraph sebagai elemen contoh.
<Paragraph
FontFamily="Century Gothic, Courier New"
FontSize="16pt"
FontStretch="UltraExpanded"
FontStyle="Italic"
FontWeight="DemiBold"
>
<Run>
This text will use the Century Gothic font (if available), with fallback to Courier New. It
will render with a font size of 16 points in ultra-expanded demi-bold italic.
</Run>
</Paragraph>
Gambar berikut menunjukkan bagaimana contoh sebelumnya dirender.
Contoh berikut menunjukkan cara mengatur properti FontStyle secara terprogram.
Run run = new Run(
"This text will use the Century Gothic font (if available), with fallback to Courier New."
+ "It will render with a font size of 16 pixels in ultra-expanded demi-bold italic.");
Paragraph par = new Paragraph(run);
par.FontFamily = new FontFamily("Century Gothic, Courier New");
par.FontSize = 16;
par.FontStretch = FontStretches.UltraExpanded;
par.FontStyle = FontStyles.Italic;
par.FontWeight = FontWeights.DemiBold;
Dim run As New Run("This text will use the Century Gothic font (if available), with fallback to Courier New." & "It will render with a font size of 16 pixels in ultra-expanded demi-bold italic.")
Dim par As New Paragraph(run)
With par
.FontFamily = New FontFamily("Century Gothic, Courier New")
.FontSize = 16
.FontStretch = FontStretches.UltraExpanded
.FontStyle = FontStyles.Italic
.FontWeight = FontWeights.DemiBold
End With
Keterangan
Properti dependensi ini juga memiliki penggunaan properti terlampir. Dalam XAML, penggunaannya adalah <object TextElement.FontStyle="value".../>, di mana objek adalah elemen objek (biasanya elemen alur) yang terkandung dalam TextElement, dan nilai adalah salah satu nama properti format string di FontStyles kelas . Dalam kode, penggunaan properti terlampir didukung oleh GetFontStyle metode dan SetFontStyle . Penggunaan properti terlampir tidak umum, karena sebagian besar elemen yang dapat dimuat dalam TextElement mendukung properti yang tidak terpasang FontStyle analog, yang digunakan host konten untuk penyajian.
Informasi Properti Dependensi
| Item | Nilai |
|---|---|
| Bidang pengidentifikasi | FontStyleProperty |
Properti metadata diatur ke true |
AffectsMeasure, , AffectsRenderInherits |