Aracılığıyla paylaş


TextBlock.TextAlignment Özellik

Tanım

Metin içeriğinin yatay hizalamasını gösteren bir değer alır veya ayarlar.

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

Özellik Değeri

TextAlignment

İstenen hizalamayı TextAlignment belirten değerlerden biri. Varsayılan değer: Left.

Örnekler

Aşağıdaki örnekte bir TextBlock öğenin özniteliğinin TextAlignment nasıl ayarlanacağı gösterilmektedir.

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

Aşağıdaki örnekte özelliğin TextAlignment program aracılığıyla nasıl ayarlanacağı gösterilmektedir.

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

Açıklamalar

Bu bağımlılık özelliğinin ekli özellik kullanımı da vardır. XAML'de kullanım, <object TextBlock.TextAlignment="value".../>nesnesinin içinde yer alan TextBlockbir nesne öğesi (genellikle bir akış öğesi) olduğu ve değerin de sabit listesinin TextAlignment dize değeri olduğu şeklindedir. Kodda, ekli özellik kullanımı ve SetTextAlignmenttarafından GetTextAlignment desteklenir. Ekli özellik kullanımı yaygın değildir.

Bağımlılık Özelliği Bilgileri

Tanımlayıcı alanı TextAlignmentProperty
Meta veri özellikleri olarak ayarlandı true AffectsMeasure, AffectsRender, Inherits

Şunlara uygulanır

Ayrıca bkz.