Block Block Block Class

Definition

An abstract class that provides a base for all block-level content elements.

public class Block : TextElement, IBlockpublic class Block : TextElement, IBlockPublic Class Block Inherits TextElement Implements IBlock
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Remarks

Block defines text formatting properties that should apply to all types of Block content. These properties are: LineHeight, LineStackingStrategy, Margin, and TextAlignment. Block also inherits the text formatting properties and other API of TextElement.

In the Windows Runtime XAML vocabulary the only block type is Paragraph. You use Paragraph to define the blocks of text to display within a RichTextBlock control. Every RichTextBlock should include at least one Paragraph.

BlockCollection is a strongly typed collection class that is used by the RichTextBlock.Blocks property. By specifying XAML object elements within a RichTextBlock, you can assign the block text content for the RichTextBlock. This is usually done using an implicit collection and XAML property syntax, such that the Paragraph elements appear as direct children of RichTextBlock in XAML markup. For example:

<RichTextBlock>
  <Paragraph>First paragraph.</Paragraph>
  <Paragraph>Second paragraph.</Paragraph>
  <Paragraph>Third paragraph. <Bold>With an inline.</Bold></Paragraph>
</RichTextBlock>

Block derived classes

Block is the parent class for Paragraph.

Migration notes

The Windows Runtime XAML vocabulary doesn't support a Section class. If you're migrating XAML from Windows Presentation Foundation (WPF) or Microsoft Silverlight, use a Paragraph block element instead.

Constructors

Block() Block() Block()

Provides base class initialization behavior for Block derived classes.

protected Block()protected Block()Protected Sub New()
Attributes

Properties

LineHeight LineHeight LineHeight

Gets or sets the height of each line of content.

public double LineHeight { get; set; }public double LineHeight { get; set; }Public ReadWrite Property LineHeight As double
<Paragraph LineHeight="double"/>
Value
double double double

The pixel height of each line as modified by LineStackingStrategy. A value of 0 indicates that the line height is determined automatically from the current font characteristics. The default is 0.

Attributes

Remarks

Block is a base class for Paragraph. Paragraph is the only element that you can set a LineHeight value on in Windows Runtime XAML, unless you create a custom class based on Block.

LineHeightProperty LineHeightProperty LineHeightProperty

Identifies the LineHeight dependency property.

public static DependencyProperty LineHeightProperty { get; }public static DependencyProperty LineHeightProperty { get; }Public Static ReadOnly Property LineHeightProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the LineHeight dependency property.

Attributes

LineStackingStrategy LineStackingStrategy LineStackingStrategy

Gets or sets a value that indicates how a line box is determined for each line of text in the Block.

public LineStackingStrategy LineStackingStrategy { get; set; }public LineStackingStrategy LineStackingStrategy { get; set; }Public ReadWrite Property LineStackingStrategy As LineStackingStrategy
<Paragraph LineStackingStrategy="BlockLineHeight"/>
-or-
<Paragraph LineStackingStrategy="MaxHeight"/>
Value
LineStackingStrategy LineStackingStrategy LineStackingStrategy

A value that indicates how a line box is determined for each line of text in the Block. The default is MaxHeight.

Attributes

Remarks

Block is a base class for Paragraph. Paragraph is the only element that you can set a LineStackingStrategy value on in Windows Runtime XAML, unless you create a custom class based on Block.

BlockLineHeight and MaxHeight are the only two constant names that exist in the LineStackingStrategy enumeration, so the XAML syntax shows those two choices.

LineStackingStrategyProperty LineStackingStrategyProperty LineStackingStrategyProperty

Identifies the LineStackingStrategy dependency property.

public static DependencyProperty LineStackingStrategyProperty { get; }public static DependencyProperty LineStackingStrategyProperty { get; }Public Static ReadOnly Property LineStackingStrategyProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the LineStackingStrategy dependency property.

Attributes

Margin Margin Margin

Gets or sets the amount of space around a Block element.

public Thickness Margin { get; set; }public Thickness Margin { get; set; }Public ReadWrite Property Margin As Thickness
<Paragraph Margin="uniform"/>
- or -
<Paragraph Margin="left+right,top+bottom"/>
- or -
<Paragraph Margin="left,top,right,bottom"/>
 
Value
Thickness Thickness Thickness

The amount of space around a Block element.

Attributes

Remarks

Code migration note Microsoft Silverlight doesn't support a Margin property on Block or Paragraph. Windows Presentation Foundation (WPF) has a Margin property on Block and Paragraph, but also has a Padding property there that the Windows Runtime doesn't support. If you need per-paragraph padding support, you might need to put each Paragraph in a different Border container and use a Panel for layout control, and set Border.Padding on each Border. Or, use RichTextBlock.

MarginProperty MarginProperty MarginProperty

Identifies the Margin dependency property.

public static DependencyProperty MarginProperty { get; }public static DependencyProperty MarginProperty { get; }Public Static ReadOnly Property MarginProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the Margin dependency property.

Attributes

TextAlignment TextAlignment TextAlignment

Gets or sets the horizontal alignment of the text content.

public TextAlignment TextAlignment { get; set; }public TextAlignment TextAlignment { get; set; }Public ReadWrite Property TextAlignment As TextAlignment
<Paragraph TextAlignment="textAlignmentMemberName"/>
Value
TextAlignment TextAlignment TextAlignment

The horizontal alignment of the text content. The default is Left.

Attributes

Remarks

Block is a base class for Paragraph. Paragraph is the only element that you can set a TextAlignment value on in Windows Runtime XAML, unless you create a custom class based on Block.

TextAlignmentProperty TextAlignmentProperty TextAlignmentProperty

Identifies the TextAlignment dependency property.

public static DependencyProperty TextAlignmentProperty { get; }public static DependencyProperty TextAlignmentProperty { get; }Public Static ReadOnly Property TextAlignmentProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the TextAlignment dependency property.

Attributes