AnchoredBlock.BorderBrush Property

Definition

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

C#
public System.Windows.Media.Brush BorderBrush { get; set; }

Property Value

The brush used to apply to the element's border. The default value is a null brush.

Examples

The following example shows how to set the BorderBrush attribute of an element (Paragraph).

XAML
<FlowDocument>
  <Paragraph Name="par"
    BorderBrush="Blue"
    BorderThickness="0.25in"
  >
    <Run>
      Child elements in this Block element (Paragraph) will be surrounded by a blue border.
    </Run>
    <LineBreak/><LineBreak/>
    <Run>
      This border will be one quarter inch thick in all directions.
    </Run>
  </Paragraph>
</FlowDocument>

The following figure shows how this example renders.

Screenshot: Blue, 1/4inch border around Block

The following example shows how to set the BorderBrush property programmatically.

C#
Paragraph par = new Paragraph();

Run run1 = new Run("Child elements in this Block element (Paragraph) will be surrounded by a blue border.");
Run run2 = new Run("This border will be one quarter inch thick in all directions.");

par.Inlines.Add(run1);
par.Inlines.Add(run2);

par.BorderBrush = Brushes.Blue;
ThicknessConverter tc = new ThicknessConverter();
par.BorderThickness = (Thickness)tc.ConvertFromString("0.25in");

Remarks

For a table of swatches that show the available pre-defined brush colors, see Brushes.

Dependency Property Information

Item Value
Identifier field BorderBrushProperty
Metadata properties set to true AffectsRender

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also