TextBlock.FontStretch Propriedade

Definição

Obtém ou define as características de alongamento da fonte de nível superior para o 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 Propriedade

Um membro da FontStretch classe que especifica as características pretendidas de esticar a fonte a usar. A predefinição é Normal.

Exemplos

O exemplo seguinte mostra como definir o FontStretch atributo de um 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>

O exemplo a seguir mostra como definir a propriedade FontStretch programaticamente.

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

Observações

Quaisquer FontStretch definições nos elementos filhos sobrepõem-se a esta definição de topo.

Esta propriedade de dependência também tem um uso associado à propriedade. Em XAML, a utilização é <object TextBlock.FontStretch="value".../>, onde o objeto é um elemento objeto (tipicamente um elemento fluxo) contido num TextBlock, e o valor é um dos nomes de propriedades de formato de strings da FontStretch classe. No código, o uso da propriedade associada é suportado por GetFontStretch e SetFontStretch. O uso da propriedade anexada não é comum, porque a maioria dos elementos que podem ser contidos num TextBlock suporte a uma propriedade não anexada FontStretch análoga, que o TextBlock uso é para renderização.

Informação de Propriedade de Dependência

Iteme Value
Campo identificador FontStretchProperty
Propriedades dos metadados definidas como true AffectsMeasure, AffectsRender, Inherits

Aplica-se a