TextElement.FontStretch 屬性

定義

取得或設定項目內容的字型自動縮放特性。

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

屬性值

FontStretch

要使用的字型延展特性。 預設為 Normal

範例

下列範例示範如何使用 做為範例專案來設定 FontStretch 屬性 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>

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

螢幕擷取畫面:已設定文字屬性的文字

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

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.FontStretch="value".../> ,其中 object 是物件 元素, (通常是流程專案) 包含在 內 TextElement ,而 是 類別的其中一個字串格式屬性名稱 FontStretch 。 在程式碼中,和 SetFontStretch 方法支援 GetFontStretch 附加屬性使用方式。 附加屬性使用方式並不常見,因為大部分可以包含在 中的 TextElement 元素都支援類似非附加 FontStretch 屬性,內容主機會用來轉譯。

相依性屬性資訊

識別碼欄位 FontStretchProperty
中繼資料屬性設定為 true AffectsMeasureAffectsRenderInherits

適用於