TextBlock.TextAlignment Eigenschap

Definitie

Hiermee wordt een waarde opgehaald of ingesteld die de horizontale uitlijning van tekstinhoud aangeeft.

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

Waarde van eigenschap

Een van de TextAlignment waarden die de gewenste uitlijning aangeeft. De standaardwaarde is Left.

Voorbeelden

In het volgende voorbeeld ziet u hoe u het TextAlignment 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 TextAlignment 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

Deze afhankelijkheidseigenschap heeft ook een gekoppeld eigenschapsgebruik. In XAML is <object TextBlock.TextAlignment="value".../>het gebruik, waarbij het object een objectelement is (meestal een stroomelement) dat in een TextBlock, en de waarde een tekenreekswaarde van de TextAlignment opsomming is. In code wordt het gebruik van gekoppelde eigenschappen ondersteund door GetTextAlignment en SetTextAlignment. Het gebruik van gekoppelde eigenschappen is niet gebruikelijk.

Informatie over afhankelijkheidseigenschappen

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

Van toepassing op

Zie ook