TextBlock.Text Egenskap

Definition

Hämtar eller anger textinnehållet i en 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

Egenskapsvärde

Textinnehållet i den här TextBlock. Observera att allt icke-textinnehåll tas bort, vilket resulterar i en oformaterad textrepresentation av TextBlock innehållet. Standardvärdet är Empty.

Attribut

Exempel

I följande exempel visas hur du anger attributet för Text ett TextBlock element.

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

Alternativt kan innehållet i en textkörning helt enkelt innehållas av TextBlock elementtaggar.

I följande exempel visas hur du ställer in Text-egenskapen programmatiskt.

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."

Kommentarer

Använd den här egenskapen när du vill visa oformaterad text i en TextBlock. När du behöver formatera texten lägger du till Inline objekt i egenskapen Inlines .

Information om beroendeegenskap

Objekt Value
Identifierarfält TextProperty
Metadataegenskaper inställda på true AffectsMeasure, AffectsRender

Gäller för