TextElement.FontSize 屬性

定義

取得或設定項目內容的字型大小。

public:
 property double FontSize { double get(); void set(double value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.FontSizeConverter))]
[System.Windows.Localizability(System.Windows.LocalizationCategory.None)]
public double FontSize { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.FontSizeConverter))>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None)>]
member this.FontSize : double with get, set
Public Property FontSize As Double

屬性值

要在裝置獨立圖元中使用的所需字型大小,大於 0.001 且小於或等於 35791。 預設值取決於目前的系統設定,而且取決於 MessageFontSize 值。

屬性

例外狀況

FontSize 設為大於 35791 或小於或等於 0.001 的值。

範例

下列範例示範如何使用 做為範例專案來設定 FontSize 屬性 Paragraph

<Paragraph
  FontFamily="Century Gothic, Courier New"  
  FontSize="16pt"
  FontStretch="UltraExpanded"
  FontStyle="Italic"
  FontWeight="DemiBold"
>
  <Run>
    This text will use the Century Gothic font (if available), with fallback to Courier New.  It 
    will render with a font size of 16 points in ultra-expanded demi-bold italic.
  </Run>
</Paragraph>

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

螢幕擷取畫面:文字屬性集的文字螢幕

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

Run run = new Run(
    "This text will use the Century Gothic font (if available), with fallback to Courier New."
    + "It will render with a font size of 16 pixels in ultra-expanded demi-bold italic.");
Paragraph par = new Paragraph(run);

par.FontFamily = new FontFamily("Century Gothic, Courier New");
par.FontSize = 16;
par.FontStretch = FontStretches.UltraExpanded;
par.FontStyle = FontStyles.Italic;
par.FontWeight = FontWeights.DemiBold;
Dim run As New Run("This text will use the Century Gothic font (if available), with fallback to Courier New." & "It will render with a font size of 16 pixels in ultra-expanded demi-bold italic.")
Dim par As New Paragraph(run)

With par
    .FontFamily = New FontFamily("Century Gothic, Courier New")
    .FontSize = 16
    .FontStretch = FontStretches.UltraExpanded
    .FontStyle = FontStyles.Italic
    .FontWeight = FontWeights.DemiBold
End With

備註

此相依性屬性也有附加屬性使用方式。 在 XAML 中,使用方式是 <object TextElement.FontSize="value".../> ,其中 object 是物件 元素 (通常是流程專案) 包含在 內 TextElement而 value 是其中一個字串格式值,如 XAML 值中所述。 在程式碼中,和 SetFontSize 方法支援 GetFontSize 附加屬性使用方式。 附加屬性使用方式並不常見,因為大部分可以包含在 中的 TextElement 元素都支援類似非附加 FontSize 屬性,內容主機會用來轉譯。

XAML Attribute Usage

<object FontSize="double"/>  
- or -  
<object FontSize="qualifiedDouble"/>  

XAML 值

double
Double

值的字串表示 Double 等於或大於 0.0,但小於 PositiveInfinity 。 不合格的值是以裝置獨立圖元來測量。 字串不需要明確包含小數點。

qualifiedDouble
如上所述的 雙精度 浮點數,後面接著下列其中一個單位規範: px 、、 incmpt 、 。

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

in 為英吋;1in==96px

cm 為公分;1cm== (96/2.54) px

pt 為點;1pt== (96/72) px

相依性屬性資訊

識別碼欄位 FontSizeProperty
設定為 的中繼資料屬性 true AffectsMeasure, AffectsRender, Inherits

適用於