TextElement.FontWeight Propiedad

Definición

Obtiene o establece el espesor de la fuente de nivel superior para el contenido del elemento.

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

Valor de propiedad

FontWeight

Peso de fuente deseado. El valor predeterminado viene determinado por el valor de MessageFontWeight.

Ejemplos

En el ejemplo siguiente se muestra cómo establecer el FontWeight atributo utilizando Paragraph como elemento de ejemplo.

<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>

En la ilustración siguiente se muestra cómo se representa el ejemplo anterior.

Captura de pantalla: texto con las propiedades de texto establecidas

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

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

Comentarios

Esta propiedad de dependencia también tiene un uso de propiedad adjunta. En XAML, el uso es <object TextElement.FontWeight="value".../>, donde object es un elemento de objeto (normalmente un elemento flow) contenido en , TextElementy value es uno de los valores de formato de cadena de la FontWeight enumeración. En el código, el uso de la propiedad adjunta es compatible con los GetFontWeight métodos y SetFontWeight . El uso de la propiedad adjunta no es común, ya que la mayoría de los elementos que se pueden contener en una TextElement propiedad análoga no adjunta FontWeight , que el host de contenido usa para la representación.

Información sobre propiedades de dependencia

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

Se aplica a