Skip to end of metadata
Go to start of metadata

Remarks

All elements that inherit from Block, will have the following configuration:

  • Border
    You can specify border decoration in block elements. You can specify different border configuration to the top, right, bottom, and left part of the border. You can also specify the background color and corner radius. For further information, see Configuring Border Formatting.
  • Line spacing
    You can specify the spacing between lines in block element using LineSpacingType and LineSpacing properties. For further information, see Configuring Line Spacing Formatting.
  • Margin
    You can specify the margin of block element using Margin property.
  • Padding
    You can specify the padding of block element using Padding property.
  • Text alignment
    You can specify the text alignment applied to block element using TextAlignment property. The available text alignment options are Left, Center, Right, and Justify.
  • Spacing before and after
    You can specify the spacing before and after the block element using SpacingBefore and SpacingAfter properties.

Elements that inherit from Block are Section, Paragraph, List, BlockUIContainer, and Table.

Working with BorderBrush Property, BorderStyle Property and BorderThickness Property

You can specify border formatting in Block elements. To specify global configuration for border, you can use BorderThickness, BorderBrush, and BorderStyle properties. BorderThickness property determines the border thickness of the element. BorderBrush property determines the Brush used to render the border.

BorderStyle property determines the line style of the border. Several predefined border style options are Single, Dot, DashDot, DashDotDot, DashLargeGap, and DashSmallGap.

XAML

Working with Borders Property

You can simplify the above configuration and use only one property, Borders, to specify the border configuration globally or individually. Borders property accepts comma and semicolon separated string. The pattern is [border width],[border line style],[border brush]. For example: Borders="1,Single,#FF000000" will set the border configuration to 1 pixel width, Single border line style, and black color brush. Note that the pattern cannot be swapped and you must use hexadecimal format to determine the border brush.

XAML

To use Borders property for individual border side configuration, repeat the pattern and separate them with semicolon. If there are two border definitions separated by semicolon, the first one will be applied to the left and right borders, and the second one will be applied to the top and bottom borders. If there are four border definitions separated by semicolon, the first one will be applied to the left border, the second one to the top border, the third one to the right border, and the last one to the bottom border. For example: Border="1,Single,#FF000000;2,Dot,#FFFF0000" will set the 1 pixel width, Single border line style, and black color brush to the left and right border, and 2 pixel width, Dot border line style, and red color brush to the top and bottom border.

XAML

Working with BottomBorderBrush Property, BottomBorderStyle Property, LeftBorderBrush Property, LeftBorderStyle Property, RightBorderBrush Property, RightBorderStyle Property, TopBorderBrush Property and TopBorderStyle Property

Besides global formatting, you can specify border thickness, brush, and style in each side of the border. For the left side of the border, you can use LeftBorderBrush and LeftBorderStyle properties. For the top side of the border, you can use TopBorderBrush and TopBorderStyle properties. For the right side of the border, you can use RightBorderBrush and RightBorderStyle properties. For the bottom side of the border, you can use BottomBorderBrush and BottomBorderStyle properties. BorderThickness uses Thickness-typed value, so you can specify the thickness of each side easily. Note that the individual border configuration will override the global border configuration.

XAML

Working with CornerRadius Property

You can set the element to use round corner border. Simply set CornerRadius property to a double value.

XAML

Working with LineSpacing Property and LineSpacingType Property

You can use LineSpacingType and LineSpacing properties to specify spacing between lines in FlowDocument elements. The following are the options of LineSpacingType property:

  • Single
    When this option is selected, there will be no spacing between the lines.
  • OneAndHalfLines
    When this option is selected, the spacing between lines will be half of the line height.
  • Double
    When this option is selected, the spacing between lines will be the same as the line height.
  • AtLeast
    When this option is selected, the line height will at least be the same with the value of LineSpacing property. For example, if LineSpacing is set to 25, the line height will at least be 25 pixel. The line height can be a larger value than 25 pixel.
  • Exactly
    When this option is selected, the line height will exactly be the same as the value of LineSpacing property. For example, if the LineSpacing is set to 25, the line height will be exactly 25 pixel. If the line height is larger than 25 pixel, the content will be clipped.
  • Multiple
    When this option is selected, the line height will use the value of LineSpacing property multiplied by 2. For example, if the LineSpacing is set to 25, the line height will be 50 pixel.

Definition

public abstract class Block : TextElement

Summary

The following table summarizes the members exposed in this class.

Protected Constructors

Public Properties

BorderBrushGets or sets a Brush to use when painting the element's border.
BordersGets or sets the comma and semicolon separated string as border value.
BorderStyleGets or sets the border style used when painting the element's border.
BorderThicknessGets or sets the border thickness of the element.
BottomBorderBrushGets or sets a Brush to use when painting the element's bottom border.
BottomBorderStyleGets or sets the border style used when painting the element's bottom border.
BreakColumnBefore 
BreakPageBefore 
CornerRadiusGets or sets the corner radius applied to the element's border.
IsHyphenationEnabled 
LeftBorderBrushGets or sets a Brush to use when painting the element's left border.
LeftBorderStyleGets or sets the border style used when painting the element's left border.
LineSpacingGets or sets the custom line spacing of the element.
LineSpacingTypeGets or sets the line spacing type of the element.
MarginGets or sets the margin thickness for the element.
PaddingGets or sets the padding thickness for the element.
RightBorderBrushGets or sets a Brush to use when painting the element's right border.
RightBorderStyleGets or sets the border style used when painting the element's right border.
SpacingAfterGets or sets the space applied after the element is rendered.
SpacingBeforeGets or sets the space before the element is rendered.
TextAlignmentGets or sets the horizontal alignment of text content.
TopBorderBrushGets or sets a Brush to use when painting the element's top border.
TopBorderStyleGets or sets the border style used when painting the element's top border.

Fields

BorderBrushPropertyIdentifies the BorderBrush dependency property.
BordersPropertyIdentifies the Borders dependency property.
BorderStylePropertyIdentifies the BorderStyle dependency property.
BorderThicknessPropertyIdentifies the BorderThickness dependency property.
BottomBorderBrushPropertyIdentifies the BottomBorderBrush dependency property.
BottomBorderStylePropertyIdentifies the BottomBorderStyle dependency property.
BreakColumnBeforePropertyIdentifies the BreakColumnBefore dependency property.
BreakPageBeforePropertyIdentifies the BreakPageBefore dependency property.
CornerRadiusPropertyIdentifies the CornerRadius dependency property.
IsHyphenationEnabledPropertyIdentifies the IsHyphenationEnabled dependency property.
LeftBorderBrushPropertyIdentifies the LeftBorderBrush dependency property.
LeftBorderStylePropertyIdentifies the LeftBorderStyle dependency property.
LineSpacingPropertyIdentifies the LineSpacing dependency property.
LineSpacingTypePropertyIdentifies the LineSpacingType dependency property.
MarginPropertyIdentifies the Margin dependency property.
PaddingPropertyIdentifies the Padding dependency property.
RightBorderBrushPropertyIdentifies the RightBorderBrush dependency property.
RightBorderStylePropertyIdentifies the RightBorderStyle dependency property.
SpacingAfterPropertyIdentifies the SpacingAfter dependency property.
SpacingBeforePropertyIdentifies the SpacingBefore dependency property.
TextAlignmentPropertyIdentifies the TextAlignment dependency property.
TopBorderBrushPropertyIdentifies the TopBorderBrush dependency property.
TopBorderStylePropertyIdentifies the TopBorderStyle dependency property.

Protected Constructors

protected Block()

 

Public Properties

public Brush BorderBrush { get; set; }

Gets or sets a Brush to use when painting the element's border.

public BorderStyle Borders { get; set; }

Gets or sets the comma and semicolon separated string as border value.

public BorderLineStyle BorderStyle { get; set; }

Gets or sets the border style used when painting the element's border.

public Thickness BorderThickness { get; set; }

Gets or sets the border thickness of the element.

public Brush BottomBorderBrush { get; set; }

Gets or sets a Brush to use when painting the element's bottom border.

public BorderLineStyle BottomBorderStyle { get; set; }

Gets or sets the border style used when painting the element's bottom border.

public bool BreakColumnBefore { get; set; }

 

public bool BreakPageBefore { get; set; }

 

public CornerRadius CornerRadius { get; set; }

Gets or sets the corner radius applied to the element's border.

public bool IsHyphenationEnabled { get; set; }

 

public Brush LeftBorderBrush { get; set; }

Gets or sets a Brush to use when painting the element's left border.

public BorderLineStyle LeftBorderStyle { get; set; }

Gets or sets the border style used when painting the element's left border.

public double LineSpacing { get; set; }

Gets or sets the custom line spacing of the element.

public LineSpacingType LineSpacingType { get; set; }

Gets or sets the line spacing type of the element.

public Thickness Margin { get; set; }

Gets or sets the margin thickness for the element.

public Thickness Padding { get; set; }

Gets or sets the padding thickness for the element.

public Brush RightBorderBrush { get; set; }

Gets or sets a Brush to use when painting the element's right border.

public BorderLineStyle RightBorderStyle { get; set; }

Gets or sets the border style used when painting the element's right border.

public double SpacingAfter { get; set; }

Gets or sets the space applied after the element is rendered.

public double SpacingBefore { get; set; }

Gets or sets the space before the element is rendered.

public TextAlignment TextAlignment { get; set; }

Gets or sets the horizontal alignment of text content.

public Brush TopBorderBrush { get; set; }

Gets or sets a Brush to use when painting the element's top border.

public BorderLineStyle TopBorderStyle { get; set; }

Gets or sets the border style used when painting the element's top border.

Fields

public static readonly DependencyProperty BorderBrushProperty

Identifies the BorderBrush dependency property.

public static readonly DependencyProperty BordersProperty

Identifies the Borders dependency property.

public static readonly DependencyProperty BorderStyleProperty

Identifies the BorderStyle dependency property.

public static readonly DependencyProperty BorderThicknessProperty

Identifies the BorderThickness dependency property.

public static readonly DependencyProperty BottomBorderBrushProperty

Identifies the BottomBorderBrush dependency property.

public static readonly DependencyProperty BottomBorderStyleProperty

Identifies the BottomBorderStyle dependency property.

public static readonly DependencyProperty BreakColumnBeforeProperty

Identifies the BreakColumnBefore dependency property.

public static readonly DependencyProperty BreakPageBeforeProperty

Identifies the BreakPageBefore dependency property.

public static readonly DependencyProperty CornerRadiusProperty

Identifies the CornerRadius dependency property.

public static readonly DependencyProperty IsHyphenationEnabledProperty

Identifies the IsHyphenationEnabled dependency property.

public static readonly DependencyProperty LeftBorderBrushProperty

Identifies the LeftBorderBrush dependency property.

public static readonly DependencyProperty LeftBorderStyleProperty

Identifies the LeftBorderStyle dependency property.

public static readonly DependencyProperty LineSpacingProperty

Identifies the LineSpacing dependency property.

public static readonly DependencyProperty LineSpacingTypeProperty

Identifies the LineSpacingType dependency property.

public static readonly DependencyProperty MarginProperty

Identifies the Margin dependency property.

public static readonly DependencyProperty PaddingProperty

Identifies the Padding dependency property.

public static readonly DependencyProperty RightBorderBrushProperty

Identifies the RightBorderBrush dependency property.

public static readonly DependencyProperty RightBorderStyleProperty

Identifies the RightBorderStyle dependency property.

public static readonly DependencyProperty SpacingAfterProperty

Identifies the SpacingAfter dependency property.

public static readonly DependencyProperty SpacingBeforeProperty

Identifies the SpacingBefore dependency property.

public static readonly DependencyProperty TextAlignmentProperty

Identifies the TextAlignment dependency property.

public static readonly DependencyProperty TopBorderBrushProperty

Identifies the TopBorderBrush dependency property.

public static readonly DependencyProperty TopBorderStyleProperty

Identifies the TopBorderStyle dependency property.

  • No labels