Block.BorderThickness 屬性

定義

取得或設定項目的框線粗細。

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

屬性值

Thickness

Thickness 結構,指定要套用的框線數量 (以與裝置無關的像素為單位)。 預設值是粗細一致的零 (0.0)。

範例

下列範例示範如何設定 BorderThickness Block 專案的屬性 () 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>

下圖顯示上述範例的呈現方式。

螢幕擷取畫面:藍色,1/4 英吋框線

下列範例示範如何以程式設計方式設定 BorderThickness 屬性。

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)

備註

XAML Attribute Usage

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

XAML 值

uniformThickness
Double 一值的字串表示,以統一套用至所有四個粗細維度。 例如, 的值 "10" 相當於 的值 "10,10,10,10" 。 不合格的值是以裝置獨立圖元來測量。 字串不需要明確包含小數點。

independentThickness
四個排序 Double 值的字串表示,以這個順序對應至左、上、右和下的獨立粗細維度。 這四個值必須以逗號分隔;不允許空格。 例如,「5,10,15,20」 會在內容左邊產生 5 圖元的框線、內容上方 10 圖元的框線、內容右邊 15 圖元的框線,以及內容下方 20 圖元的框線。

qualifiedUniformThickness
由 uniformThickness 所描述的值,後面接著下列其中一個單位規範: pxin

px (預設) 是裝置獨立單位 (,每單位 1/96 英吋)

in 為英吋;1in==96px

例如, "1in" 提供所有方向的統一框線 1 英吋。

qualifiedIndependentThickness
independentThickness 所描述的值,每個獨立值後面接著下列其中一個單位規範: pxin

px (預設) 是裝置獨立單位 (,每單位 1/96 英吋)

in 為英吋;1in==96px

例如: "1.5in,0.8in,1.5in,0.8in" 。 單位規範可以從一或多個值混合或省略。

相依性屬性資訊

識別碼欄位 BorderThicknessProperty
中繼資料屬性設定為 true AffectsMeasure

適用於

另請參閱