Aracılığıyla paylaş


TextBlock.Foreground Özellik

Tanım

öğesini alır veya öğesinin metin içeriğine TextBlockuygulanacak şekilde ayarlarBrush.

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

Özellik Değeri

Metin içeriğine uygulamak için kullanılan fırça. Varsayılan değer: Black.

Örnekler

Aşağıdaki örnekte bir TextBlock öğenin özniteliğinin Foreground 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, Foreground özelliğinin 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

Kullanılabilir önceden tanımlanmış fırça renklerini gösteren renk örnekleri tablosu için bkz Brushes. .

Alt öğelerdeki tüm Foreground ayarlar bu üst düzey ayarı geçersiz kılar.

Bu bağımlılık özelliğinin ekli özellik kullanımı da vardır. XAML'de kullanım, <object TextBlock.Foreground="value".../>nesnenin içinde yer alan TextBlockbir nesne öğesi (genellikle akış öğesi), değer ise bir uygulama değerine çözümlenen bir Brush dize olduğu şeklindedir. Kodda, ekli özellik kullanımı ve SetForegroundtarafından GetForeground desteklenir. Ekli özellik kullanımı yaygın değildir, çünkü bir TextBlock içinde bulunabilecek öğelerin çoğu, işleme için kullanılan benzer bir eklenmemiş Foreground özelliği TextBlock destekler.

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

Öğe Değer
Tanımlayıcı alanı ForegroundProperty
Meta veri özellikleri olarak ayarlandı true AffectsRender, SubPropertiesDoNotAffectRender, Inherits

Şunlara uygulanır