TextBlock 构造函数

定义

初始化 TextBlock 类的新实例。Initializes a new instance of the TextBlock class.

重载

TextBlock()

初始化 TextBlock 类的新实例。Initializes a new instance of the TextBlock class.

TextBlock(Inline)

初始化 TextBlock 类的一个新实例,将指定的 Inline 元素作为初始显示内容添加。Initializes a new instance of the TextBlock class, adding a specified Inline element as the initial display content.

TextBlock()

初始化 TextBlock 类的新实例。Initializes a new instance of the TextBlock class.

public:
 TextBlock();
public TextBlock ();
Public Sub New ()

TextBlock(Inline)

初始化 TextBlock 类的一个新实例,将指定的 Inline 元素作为初始显示内容添加。Initializes a new instance of the TextBlock class, adding a specified Inline element as the initial display content.

public:
 TextBlock(System::Windows::Documents::Inline ^ inline);
public TextBlock (System.Windows.Documents.Inline inline);
new System.Windows.Controls.TextBlock : System.Windows.Documents.Inline -> System.Windows.Controls.TextBlock

参数

inline
Inline

要作为初始内容添加的、从 Inline 抽象类派生的对象。An object deriving from the abstract Inline class, to be added as the initial content.

异常

inlinenullinline is null.

示例

下面的示例演示如何使用此构造函数。The following example demonstrates the use of this constructor. 在这种情况下,TextBlock 包含文本 RunIn this case, the TextBlock contains a text Run.

TextBlock txtBlock = new TextBlock(new Run("A bit of text content..."));
Dim txtBlock As New TextBlock(New Run("A bit of text content..."))

注解

inline 的有效输入类型包括 AnchoredBlockInlineUIContainerLineBreakRunSpanValid input types for inline include AnchoredBlock, InlineUIContainer, LineBreak, Run, and Span.

适用于