Freigeben über


BulletDecorator.Background Eigenschaft

Definition

Dient zum Abrufen oder Festlegen der Hintergrundfarbe für ein BulletDecorator Steuerelement.

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

Eigenschaftswert

Die Hintergrundfarbe für das Bullet und Child eines .BulletDecorator Der Standardwert lautet null.

Beispiele

Die folgenden Beispiele zeigen, wie die Background Eigenschaft für ein BulletDecorator Steuerelement festgelegt wird.

BulletDecorator myBulletDecorator = new BulletDecorator();
Image myImage = new Image();
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"pack://application:,,/images/apple.jpg");
myBitmapImage.EndInit();
myImage.Source = myBitmapImage;
myImage.Width = 10;
myBulletDecorator.Bullet = myImage;
myBulletDecorator.Margin = new Thickness(0, 10, 0, 0);
myBulletDecorator.VerticalAlignment = VerticalAlignment.Center;
myBulletDecorator.Background = Brushes.Yellow;
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "This BulletDecorator created by using code";
myTextBlock.TextWrapping = TextWrapping.Wrap;
myTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
myTextBlock.Width = 100;
myTextBlock.Foreground = Brushes.Purple;
myBulletDecorator.Child = myTextBlock;
Dim myBulletDecorator = New BulletDecorator()
Dim myImage = New Image()
Dim myBitmapImage = New BitmapImage()
myBitmapImage.BeginInit()
myBitmapImage.UriSource = _
   New Uri("pack://application:,,/images/apple.jpg")
myBitmapImage.EndInit()
myImage.Source = myBitmapImage
myImage.Width = 10
myBulletDecorator.Bullet = myImage
myBulletDecorator.Margin = New Thickness(0, 10, 0, 0)
myBulletDecorator.VerticalAlignment = VerticalAlignment.Center
myBulletDecorator.Background = Brushes.Yellow
Dim myTextBlock = New TextBlock()
myTextBlock.Text = "This BulletDecorator created by using code"
myTextBlock.TextWrapping = TextWrapping.Wrap
myTextBlock.HorizontalAlignment = HorizontalAlignment.Left
myTextBlock.Width = 100
myTextBlock.Foreground = Brushes.Purple
myBulletDecorator.Child = myTextBlock
<BulletDecorator  Grid.Row="1" Grid.Column="0" Margin="0,5,0,0"
                  VerticalAlignment="Center" Background="Yellow">
  <BulletDecorator.Bullet>
    <Image Source="images\apple.jpg"/>
  </BulletDecorator.Bullet>
  <TextBlock
    Width="100" 
    TextWrapping="Wrap" 
    HorizontalAlignment="Left"
    Foreground ="Purple">
    A Simple BulletDecorator
  </TextBlock>
</BulletDecorator>

Hinweise

Die Background Eigenschaft definiert die Brush zu verwendende Eigenschaft, um den Bereich innerhalb des BulletDecoratorBereichs auszufüllen. Bei einigen übergeordneten Layoutelementen kann der bereich, der für den BulletDecorator Inhalt definiert ist, über seinen Bullet Inhalt Child hinausgehen. Wenn es BulletDecorator sich beispielsweise um das einzelne untergeordnete Element einer Zelle in einem Grid Steuerelement handelt, gilt die Background Eigenschaft für die gesamte Zelle. Dies tritt auf, da der Inhalt in einer Grid Zelle standardmäßig in alle Richtungen gestreckt wird, um die Zelle auszufüllen. Wenn Sie die VerticalAlignment Eigenschaft jedoch für die BulletDecoratorEigenschaft Center festlegen, wirkt sich die Background Eigenschaft nur auf den tatsächlichen Inhaltsbereich der BulletDecorator. Alternativ können Sie das BulletDecorator Element in ein Panel Element einschließen.

Informationen zur Abhängigkeitseigenschaft

Element Wert
Bezeichnerfeld BackgroundProperty
Auf Metadateneigenschaften festgelegt true AffectsRender, SubPropertiesDoNotAffectRender

Gilt für:

Weitere Informationen