TextBlock.Text Properti

Definisi

Mendapatkan atau mengatur konten teks dari TextBlock.

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
[System.Windows.Localizability(System.Windows.LocalizationCategory.Text)]
public string Text { get; set; }
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Text)>]
member this.Text : string with get, set
Public Property Text As String

Nilai Properti

Isi teks dari ini TextBlock. Perhatikan bahwa semua konten non-teks dilucuti, menghasilkan representasi teks biasa dari TextBlock konten. Default adalah Empty.

Atribut

Contoh

Contoh berikut menunjukkan cara mengatur Text atribut TextBlock elemen.

<TextBlock Text="The text contents of this TextBlock element."/>

Secara bergantian, konten eksekusi teks mungkin hanya dimuat oleh TextBlock tag elemen.

Contoh berikut menunjukkan cara mengatur Text properti secara terprogram.

TextBlock textBlock = new TextBlock();
textBlock.Text = "The text contents of this TextBlock.";
Dim textBlock As New TextBlock()
textBlock.Text = "The text contents of this TextBlock."

Keterangan

Gunakan properti ini saat Anda ingin menampilkan teks biasa dalam TextBlock. Saat Anda perlu memformat teks, tambahkan Inline objek ke Inlines properti .

Informasi Properti Dependensi

Bidang pengidentifikasi TextProperty
Properti metadata diatur ke true AffectsMeasure, AffectsRender

Berlaku untuk