This documentation is archived and is not being maintained.

TextBlock.TextBlock(Inline) Constructor

Initializes a new instance of the TextBlock class, adding a specified Inline element as the initial display content.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)

public TextBlock (
	Inline inline
)
public TextBlock (
	Inline inline
)
public function TextBlock (
	inline : Inline
)
You cannot use constructors in XAML.

Parameters

inline

An object deriving from the abstract Inline class, to be added as the initial content.

Exception typeCondition

ArgumentNullException

Raised if inline is null.

Valid input types for inline include AnchoredBlock, InlineUIContainer, LineBreak, Run, and Span.

The following example demonstrates usage of this constructor. In this case, the TextBlock will simply contain a text Run.

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: