Block Block Block Class

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

Syntax

Declaration

public class Blockpublic class BlockPublic Class Block

Inheritance Hierarchy

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 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:xaml <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 summary

Provides base class initialization behavior for Block derived classes.

Properties summary

Gets or sets the height of each line of content.

Identifies the LineHeight dependency property.

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

Identifies the LineStackingStrategy dependency property.

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

Identifies the Margin dependency property.

Gets or sets the horizontal alignment of the text content.

Identifies the TextAlignment dependency property.

Constructors

  • Block()
    Block()
    Block()
    Block()

    Provides base class initialization behavior for Block derived classes.

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

Properties

  • LineHeight
    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 doublepublic double LineHeight { get; set; }
    <Paragraph LineHeight="double"/>
    

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

    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
    LineHeightProperty

    Identifies the LineHeight dependency property.

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

    Property Value

  • LineStackingStrategy
    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 LineStackingStrategypublic LineStackingStrategy LineStackingStrategy { get; set; }
    <Paragraph LineStackingStrategy="BlockLineHeight"/>
    -or-
    <Paragraph LineStackingStrategy="MaxHeight"/>
    

    Property Value

    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
    LineStackingStrategyProperty

    Identifies the LineStackingStrategy dependency property.

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

    Property Value

  • Margin
    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 Thicknesspublic Thickness Margin { get; set; }
    <Paragraph Margin="uniform"/>
    - or -
    <Paragraph Margin="left+right,top+bottom"/>
    - or -
    <Paragraph Margin="left,top,right,bottom"/>
     
    

    Property Value

    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 Padding on each Border. Or, use RichTextBlock.

  • MarginProperty
    MarginProperty
    MarginProperty
    MarginProperty

    Identifies the Margin dependency property.

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

    Property Value

  • TextAlignment
    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 TextAlignmentpublic TextAlignment TextAlignment { get; set; }
    <Paragraph TextAlignment="textAlignmentMemberName"/>
    

    Property Value

    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
    TextAlignmentProperty

    Identifies the TextAlignment dependency property.

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

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ComposableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Documents.dll