Block Class

Definition

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

Equivalent WinUI class: Microsoft.UI.Xaml.Documents.Block.

public ref class Block : TextElement
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Documents.IBlockFactory, Windows.Foundation.Metadata.CompositionType.Protected, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Documents.IBlockStatics, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
class Block : TextElement
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Documents.IBlockFactory, Windows.Foundation.Metadata.CompositionType.Protected, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Documents.IBlockStatics, 65536, "Windows.Foundation.UniversalApiContract")]
class Block : TextElement
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Documents.IBlockFactory, Windows.Foundation.Metadata.CompositionType.Protected, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Documents.IBlockStatics, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Documents.IBlockStatics2, 327680, "Windows.Foundation.UniversalApiContract")]
class Block : TextElement
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Documents.IBlockFactory), Windows.Foundation.Metadata.CompositionType.Protected, 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Documents.IBlockStatics), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
public class Block : TextElement
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Documents.IBlockFactory), Windows.Foundation.Metadata.CompositionType.Protected, 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Documents.IBlockStatics), 65536, "Windows.Foundation.UniversalApiContract")]
public class Block : TextElement
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Documents.IBlockFactory), Windows.Foundation.Metadata.CompositionType.Protected, 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Documents.IBlockStatics), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Documents.IBlockStatics2), 327680, "Windows.Foundation.UniversalApiContract")]
public class Block : TextElement
Public Class Block
Inherits TextElement
Inheritance
Derived
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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.

Version history

Windows version SDK version Value added
1709 16299 HorizontalTextAlignment

Constructors

Block()

Provides base class initialization behavior for Block derived classes.

Equivalent WinUI constructor: Microsoft.UI.Xaml.Documents.Block.Block.

Properties

AccessKey

Gets or sets the access key for this element.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.AccessKey.

(Inherited from TextElement)
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.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.AccessKeyScopeOwner.

(Inherited from TextElement)
AllowFocusOnInteraction

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.AllowFocusOnInteraction.

(Inherited from TextElement)
CharacterSpacing

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.CharacterSpacing.

(Inherited from TextElement)
ContentEnd

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.ContentEnd.

(Inherited from TextElement)
ContentStart

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.ContentStart.

(Inherited from TextElement)
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.

Equivalent WinUI property: Microsoft.UI.Xaml.DependencyObject.Dispatcher.

(Inherited from DependencyObject)
ElementEnd

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.ElementEnd.

(Inherited from TextElement)
ElementStart

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.ElementStart.

(Inherited from TextElement)
ExitDisplayModeOnAccessKeyInvoked

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.ExitDisplayModeOnAccessKeyInvoked.

(Inherited from TextElement)
FontFamily

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.FontFamily.

(Inherited from TextElement)
FontSize

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.FontSize.

(Inherited from TextElement)
FontStretch

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.FontStretch.

(Inherited from TextElement)
FontStyle

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.FontStyle.

(Inherited from TextElement)
FontWeight

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.FontWeight.

(Inherited from TextElement)
Foreground

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.Foreground.

(Inherited from TextElement)
HorizontalTextAlignment

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.HorizontalTextAlignment.

HorizontalTextAlignmentProperty

Identifies the HorizontalTextAlignment dependency property.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.HorizontalTextAlignmentProperty.

IsAccessKeyScope

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.IsAccessKeyScope.

(Inherited from TextElement)
IsTextScaleFactorEnabled

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.IsTextScaleFactorEnabled.

(Inherited from TextElement)
KeyTipHorizontalOffset

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.KeyTipHorizontalOffset.

(Inherited from TextElement)
KeyTipPlacementMode

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.KeyTipPlacementMode.

(Inherited from TextElement)
KeyTipVerticalOffset

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.KeyTipVerticalOffset.

(Inherited from TextElement)
Language

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.Language.

(Inherited from TextElement)
LineHeight

Gets or sets the height of each line of content.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.LineHeight.

LineHeightProperty

Identifies the LineHeight dependency property.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.LineHeightProperty.

LineStackingStrategy

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.LineStackingStrategy.

LineStackingStrategyProperty

Identifies the LineStackingStrategy dependency property.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.LineStackingStrategyProperty.

Margin

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.Margin.

MarginProperty

Identifies the Margin dependency property.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.MarginProperty.

Name

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.Name.

(Inherited from TextElement)
TextAlignment

Gets or sets the horizontal alignment of the text content.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.TextAlignment.

TextAlignmentProperty

Identifies the TextAlignment dependency property.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.Block.TextAlignmentProperty.

TextDecorations

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

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.TextDecorations.

(Inherited from TextElement)
XamlRoot

Gets or sets the XamlRoot in which this element is being viewed.

Equivalent WinUI property: Microsoft.UI.Xaml.Documents.TextElement.XamlRoot.

(Inherited from TextElement)

Methods

ClearValue(DependencyProperty)

Clears the local value of a dependency property.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.ClearValue.

(Inherited from DependencyObject)
FindName(String)

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

Equivalent WinUI method: Microsoft.UI.Xaml.Documents.TextElement.FindName.

(Inherited from TextElement)
GetAnimationBaseValue(DependencyProperty)

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

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.GetAnimationBaseValue.

(Inherited from DependencyObject)
GetValue(DependencyProperty)

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

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.GetValue.

(Inherited from DependencyObject)
OnDisconnectVisualChildren()

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

Equivalent WinUI method: Microsoft.UI.Xaml.Documents.TextElement.OnDisconnectVisualChildren.

(Inherited from TextElement)
ReadLocalValue(DependencyProperty)

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

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.ReadLocalValue.

(Inherited from DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

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

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.RegisterPropertyChangedCallback.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object)

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

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.SetValue.

(Inherited from DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

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

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObject.UnregisterPropertyChangedCallback.

(Inherited from DependencyObject)

Events

AccessKeyDisplayDismissed

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

Equivalent WinUI event: Microsoft.UI.Xaml.Documents.TextElement.AccessKeyDisplayDismissed.

(Inherited from TextElement)
AccessKeyDisplayRequested

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

Equivalent WinUI event: Microsoft.UI.Xaml.Documents.TextElement.AccessKeyDisplayRequested.

(Inherited from TextElement)
AccessKeyInvoked

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

Equivalent WinUI event: Microsoft.UI.Xaml.Documents.TextElement.AccessKeyInvoked.

(Inherited from TextElement)

Applies to

See also