TextBlock.FontWeight Eigenschap

Definitie

Hiermee haalt of stelt u het lettertype op het hoogste niveau voor de TextBlock.

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

Waarde van eigenschap

Een lid van de FontWeights klasse waarin het gewenste lettertypegewicht wordt opgegeven. De standaardwaarde wordt bepaald door de MessageFontWeight waarde.

Voorbeelden

In het volgende voorbeeld ziet u hoe u het FontWeight kenmerk van een TextBlock element instelt.

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

In het volgende voorbeeld ziet u hoe u de eigenschap FontWeight programmatisch instelt.

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

Opmerkingen

Alle FontWeight instellingen op onderliggende elementen overschrijven deze instelling op het hoogste niveau.

Zie de FontWeights klasse voor een lijst met geldige waarden voor tekengewichten.

Deze afhankelijkheidseigenschap heeft ook een gekoppeld eigenschapsgebruik. In XAML is <object TextBlock.FontWeight="value".../>het gebruik, waarbij het object een objectelement is (meestal een stroomelement) in een TextBlock, en de waarde een van de tekenreekswaarden van een eigenschap van de FontWeights klasse is. In code wordt het gebruik van gekoppelde eigenschappen ondersteund door GetFontWeight en SetFontWeight. Het gebruik van gekoppelde eigenschappen is niet gebruikelijk, omdat de meeste elementen die kunnen worden opgenomen in een TextBlock ondersteuning voor een analoge niet-gekoppelde FontWeight eigenschap, die wordt TextBlock gebruikt voor rendering.

Informatie over afhankelijkheidseigenschappen

Item Waarde
Id-veld FontWeightProperty
Eigenschappen van metagegevens ingesteld op true AffectsMeasure, , AffectsRenderInherits

Van toepassing op