Compartir a través de


IXRTextBlock::SetText (Compact 2013)

3/28/2014

This method sets the text contents of this text block.

Syntax

virtual HRESULT STDMETHODCALLTYPE SetText(
    WCHAR* Text
) = 0;

Parameters

  • Text
    [in] Pointer to a string that contains the new text contents of this text block.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

The IXRTextBlock object is the primary text element for displaying text in XAML for Windows Embedded-based applications.

A text block can be thought of as having two object models, as follows:

  • A representation as a Text property, which represents only string content. The text has no formatting other than the formatting that is declared by using the methods on the IXRTextBlock class.
  • A representation as an IXRInlineCollection. The collection contains primarily IXRRun objects, each of which can declare its own formatting properties such as FontSize by using the methods that it inherits from IXRTextElement. The Text property returns a value. This value is the appended text of all IXRRun objects in the IXRInlineCollection. However, the returned value does not include any formatting that was applied to the IXRRun objects. If the inline collection is created from XAML as the inner text of an IXRTextBlock object, or if it is created by calling IXRTextBlock::SetText, the IXRInlineCollection contains a single IXRRun that contains the text.

You can work with either object model. However, if the text consists of a series of text elements that have individual formatting in an IXRInlineCollection, and if you modify the text by appending to the Text value, you will flatten the previous IXRInlineCollection content and replace it with a single, unformatted IXRRun with the new text.

To access text in this text block as string content, use IXRTextBlock::GetText and IXRTextBlock::SetText. To access text in this text block as an inline collection, use IXRTextBlock::GetInlines and IXRTextBlock::SetInlines.

.NET Framework Equivalent

System.Windows.Controls.TextBlock.Text

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRTextBlock
IXRTextBlock::GetText