편집

다음을 통해 공유


AnchoredBlock.BorderThickness Property

Definition

Gets or sets the border thickness for the element.

public:
 property System::Windows::Thickness BorderThickness { System::Windows::Thickness get(); void set(System::Windows::Thickness value); };
public System.Windows.Thickness BorderThickness { get; set; }
member this.BorderThickness : System.Windows.Thickness with get, set
Public Property BorderThickness As Thickness

Property Value

A Thickness structure specifying the amount of border to apply, in device independent pixels.

The default value is a uniform thickness of zero (0.0).

Examples

The following example shows how to set the BorderThickness attribute of a Block element (Paragraph).

<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 BorderThickness property programmatically.

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");
Dim par As New Paragraph()

Dim run1 As New Run("Child elements in this Block element (Paragraph) will be surrounded by a blue border.")
Dim run2 As 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
Dim tc As New ThicknessConverter()
par.BorderThickness = CType(tc.ConvertFromString("0.25in"), Thickness)

Remarks

XAML Attribute Usage

<object BorderThickness="uniformThickness"/>  
- or -  
<object BorderThickness="independentThickness"/>  
- or -  
<object BorderThickness="qualifiedUniformThickness"/>  
- or -  
<object BorderThickness="qualifiedIndependentThickness"/>  

XAML Values

uniformThickness
String representation of a single Double value to apply uniformly to all four thickness dimensions. For example, a value of "10" is equivalent to a value of "10,10,10,10". An unqualified value is measured in device independent pixels. Strings need not explicitly include decimal points.

independentThickness
String representation of four ordered Double values corresponding to independent thickness dimensions for left, top, right, and bottom, in this order. The four values must be separated with commas; spaces are not allowed. For example, "5,10,15,20" results in 5 pixels of border to the left of content, 10 pixels of border above content, 15 pixels of border to the right of content, and 20 pixels of border below the content.

qualifiedUniformThickness
A value described by uniformThickness followed by one of the following unit specifiers: px, in.

px (default) is device-independent units (1/96th inch per unit)

in is inches; 1in==96px

For example, "1in" provides uniform border of 1 inch in all directions.

qualifiedIndependentThickness
A value described by independentThickness, with each independent value followed by one of the following unit specifiers: px, in.

px (default) is device-independent units (1/96th inch per unit)

in is inches; 1in==96px

For example, "1.5in,0.8in,1.5in,0.8in". Unit specifiers may be mixed or omitted from one or more values.

Dependency Property Information

Identifier field BorderThicknessProperty
Metadata properties set to true AffectsMeasure

Applies to

See also