Share via


TextBlock.FontStretch Propiedad

Definición

Obtiene o establece las características de ajuste de fuentes de nivel superior para el TextBlock.

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

Valor de propiedad

FontStretch

Miembro de la clase FontStretch que especifica las características de ajuste de fuentes deseadas que se usarán. De manera predeterminada, es Normal.

Ejemplos

En el ejemplo siguiente se muestra cómo establecer el FontStretch atributo de un TextBlock elemento .

<TextBlock 
  Name="textBlock"
  
  Background="AntiqueWhite" 
  Foreground="Navy" 
  
  FontFamily="Century Gothic"
  FontSize="12"
  FontStretch="UltraExpanded"
  FontStyle="Italic"
  FontWeight="UltraBold"
  
  LineHeight="Auto"
  Padding="5,10,5,10"
  TextAlignment="Center"
  TextWrapping="Wrap"
  
  Typography.NumeralStyle="OldStyle"
  Typography.SlashedZero="True"
>
  <Run Background="LightGreen">Text run 1.</Run>
  <LineBreak/><Run Background="LightBlue">Text run 2.</Run>
  <LineBreak/><Run Background="LightYellow">Text run 3.</Run>
</TextBlock>

En el ejemplo siguiente se muestra cómo establecer la FontStretch propiedad mediante programación.

TextBlock textBlock = new TextBlock(new Run("A bit of text content..."));

textBlock.Background              = Brushes.AntiqueWhite;
textBlock.Foreground              = Brushes.Navy;

textBlock.FontFamily              = new FontFamily("Century Gothic");
textBlock.FontSize                = 12;
textBlock.FontStretch             = FontStretches.UltraExpanded;
textBlock.FontStyle               = FontStyles.Italic;
textBlock.FontWeight              = FontWeights.UltraBold;

textBlock.LineHeight              = Double.NaN;
textBlock.Padding                 = new Thickness(5, 10, 5, 10);
textBlock.TextAlignment           = TextAlignment.Center;
textBlock.TextWrapping            = TextWrapping.Wrap;

textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle;
textBlock.Typography.SlashedZero  = true;
Dim textBlock As New TextBlock(New Run("A bit of text content..."))

textBlock.Background = Brushes.AntiqueWhite
textBlock.Foreground = Brushes.Navy

textBlock.FontFamily = New FontFamily("Century Gothic")
textBlock.FontSize = 12
textBlock.FontStretch = FontStretches.UltraExpanded
textBlock.FontStyle = FontStyles.Italic
textBlock.FontWeight = FontWeights.UltraBold

textBlock.LineHeight = Double.NaN
textBlock.Padding = New Thickness(5, 10, 5, 10)
textBlock.TextAlignment = TextAlignment.Center
textBlock.TextWrapping = TextWrapping.Wrap

textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle
textBlock.Typography.SlashedZero = True

Comentarios

Cualquier FontStretch configuración de los elementos secundarios invalida esta configuración de nivel superior.

Esta propiedad de dependencia también tiene un uso de propiedad adjunta. En XAML, el uso es <object TextBlock.FontStretch="value".../>, donde object es un elemento de objeto (normalmente un elemento flow) contenido dentro de , TextBlocky value es uno de los nombres de propiedad de formato de cadena de la FontStretch clase. En el código, el uso de la propiedad adjunta es compatible con GetFontStretch y SetFontStretch. El uso de la propiedad adjunta no es común, ya que la mayoría de los elementos que se pueden contener en una TextBlock compatibilidad con una propiedad análoga no adjunta FontStretch , que usa TextBlock para la representación.

Información sobre propiedades de dependencia

Campo identificador FontStretchProperty
Propiedades de metadatos establecidas en true AffectsMeasure, AffectsRender, Inherits

Se aplica a