Block Block Block Class

Definition

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

public : class Block : TextElement, IBlock
public class Block : TextElement, IBlock
Public 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)

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()

Properties

AccessKey AccessKey AccessKey

Gets or sets the access key for this element.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyProperty AccessKeyProperty AccessKeyProperty

Identifies the AccessKey dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AccessKeyScopeOwner AccessKeyScopeOwner AccessKeyScopeOwner

Gets or sets a source element that provides the access key scope for this element, even if it's not in the visual tree of the source element.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty AccessKeyScopeOwnerProperty

Identifies the AccessKeyScopeOwner dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

AllowFocusOnInteraction AllowFocusOnInteraction AllowFocusOnInteraction

Gets or sets a value that indicates whether the element automatically gets focus when the user interacts with it.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty AllowFocusOnInteractionProperty

Identifies the AllowFocusOnInteraction dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

CharacterSpacing CharacterSpacing CharacterSpacing

Gets or sets the uniform spacing between characters, in units of 1/1000 of an em.

(Inherited from TextElement)

CharacterSpacingProperty CharacterSpacingProperty CharacterSpacingProperty

Identifies the CharacterSpacing dependency property.

(Inherited from TextElement)

ContentEnd ContentEnd ContentEnd

Gets a TextPointer that represents the end of the content in the element.

(Inherited from TextElement)

ContentStart ContentStart ContentStart

Gets a TextPointer that represents the start of content in the element.

(Inherited from TextElement)

Dispatcher Dispatcher Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)

ElementEnd ElementEnd ElementEnd

Gets a TextPointer that represents the position just after the end of the element.

(Inherited from TextElement)

ElementStart ElementStart ElementStart

Gets a TextPointer that represents the position just before the start of the element.

(Inherited from TextElement)

ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked ExitDisplayModeOnAccessKeyInvoked

Gets or sets a value that specifies whether the access key display is dismissed when an access key is invoked.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty ExitDisplayModeOnAccessKeyInvokedProperty

Identifies the ExitDisplayModeOnAccessKeyInvoked dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

FontFamily FontFamily FontFamily

Gets or sets the preferred top-level font family for the content of the element.

(Inherited from TextElement)

FontFamilyProperty FontFamilyProperty FontFamilyProperty

Identifies the FontFamily dependency property.

(Inherited from TextElement)

FontSize FontSize FontSize

Gets or sets the font size for the content of the element.

(Inherited from TextElement)

FontSizeProperty FontSizeProperty FontSizeProperty

Identifies the FontSize dependency property.

(Inherited from TextElement)

FontStretch FontStretch FontStretch

Gets or sets the glyph width of the font in a family to select.

(Inherited from TextElement)

FontStretchProperty FontStretchProperty FontStretchProperty

Identifies the FontStretch dependency property.

(Inherited from TextElement)

FontStyle FontStyle FontStyle

Gets or sets the font style for the content in this element.

(Inherited from TextElement)

FontStyleProperty FontStyleProperty FontStyleProperty

Identifies the FontStyle dependency property.

(Inherited from TextElement)

FontWeight FontWeight FontWeight

Gets or sets the top-level font weight to select from the font family for the content in this element.

(Inherited from TextElement)

FontWeightProperty FontWeightProperty FontWeightProperty

Identifies the FontWeight dependency property.

(Inherited from TextElement)

Foreground Foreground Foreground

Gets or sets the Brush to apply to the content in this element.

(Inherited from TextElement)

ForegroundProperty ForegroundProperty ForegroundProperty

Identifies the Foreground dependency property.

(Inherited from TextElement)

HorizontalTextAlignment HorizontalTextAlignment HorizontalTextAlignment

Gets or sets a value that indicates how text is aligned in the Block.

public : TextAlignment HorizontalTextAlignment { get; set; }
public TextAlignment HorizontalTextAlignment { get; set; }
Public ReadWrite Property HorizontalTextAlignment As TextAlignment
<Paragraph HorizontalTextAlignment="textAlignmentValue"/>

Value
TextAlignment TextAlignment TextAlignment

One of the TextAlignment enumeration values that specifies how text is aligned. The default is Left.

Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

This property supports XAML Standard. It provides the same functionality as the TextAlignement property. If both properties are set to conflicting values, the last one set is used.

HorizontalTextAlignmentProperty HorizontalTextAlignmentProperty HorizontalTextAlignmentProperty

Identifies the HorizontalTextAlignment dependency property.

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

The identifier for the HorizontalTextAlignment dependency property.

Additional features and requirements
Device family
Windows 10 Fall Creators Update (introduced v10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

IsAccessKeyScope IsAccessKeyScope IsAccessKeyScope

Gets or sets a value that indicates whether an element defines its own access key scope.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

IsAccessKeyScopeProperty IsAccessKeyScopeProperty IsAccessKeyScopeProperty

Identifies the IsAccessKeyScope dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

IsTextScaleFactorEnabled IsTextScaleFactorEnabled IsTextScaleFactorEnabled

Gets or sets whether automatic text enlargement, to reflect the system text size setting, is enabled.

(Inherited from TextElement)

IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty IsTextScaleFactorEnabledProperty

Identifies the IsTextScaleFactorEnabled dependency property.

(Inherited from TextElement)

KeyTipHorizontalOffset KeyTipHorizontalOffset KeyTipHorizontalOffset

Gets or sets a value that indicates how far left or right the keytip is placed in relation to the text element.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty KeyTipHorizontalOffsetProperty

Identifies the KeyTipHorizontalOffset dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipPlacementMode KeyTipPlacementMode KeyTipPlacementMode

Gets or sets a value that indicates where the KeyTip is placed in relation to the text element.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipPlacementModeProperty KeyTipPlacementModeProperty KeyTipPlacementModeProperty

Identifies the KeyTipPlacementMode dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipVerticalOffset KeyTipVerticalOffset KeyTipVerticalOffset

Gets or sets a value that indicates how far up or down the keytip is placed in relation to the text element.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty KeyTipVerticalOffsetProperty

Identifies the KeyTipVerticalOffset dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Language Language Language

Gets or sets localization/globalization language information that applies to a TextElement.

(Inherited from TextElement)

LanguageProperty LanguageProperty LanguageProperty

Identifies the Language dependency property.

(Inherited from TextElement)

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.

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.

See Also

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.

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.

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.

See Also

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.

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.

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.

See Also

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.

Name Name Name

Gets or sets a unique identification for the object. Name can only be set from initial parsing of XAML.

(Inherited from TextElement)

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.

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.

TextDecorations TextDecorations TextDecorations

Gets or sets a value that indicates what decorations are applied to the text.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

TextDecorationsProperty TextDecorationsProperty TextDecorationsProperty

Identifies the TextDecorations dependency property.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Events

AccessKeyDisplayDismissed AccessKeyDisplayDismissed AccessKeyDisplayDismissed

Occurs when the access key sequence is complete to notify controls that they should hide access key visuals.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

AccessKeyDisplayRequested AccessKeyDisplayRequested AccessKeyDisplayRequested

Occurs when the access key sequence is started to notify controls that they should show access key visuals.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

AccessKeyInvoked AccessKeyInvoked AccessKeyInvoked

Occurs when a user completes an access key sequence to notify the element that the access key action should be invoked.

(Inherited from TextElement)
Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Methods

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)

FindName(String) FindName(String) FindName(String)

Retrieves an object in the object model / runtime object graph by referencing the object's x:Name or Name attribute value.

(Inherited from TextElement)

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)

OnDisconnectVisualChildren OnDisconnectVisualChildren OnDisconnectVisualChildren

Override this method to implement how layout and logic should behave when items are removed from a class-specific content or child property.

(Inherited from TextElement)

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

See Also