Share via


BulletDecorator.Background Eigenschaft

Definition

Ruft die Hintergrundfarbe für ein BulletDecorator-Steuerelement ab oder legt diese fest.

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

Brush

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

Beispiele

In den folgenden Beispielen wird gezeigt, wie Sie die Background Eigenschaft auf einem BulletDecorator Steuerelement festlegen.

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 Verwendung, um den Brush Bereich innerhalb des BulletDecoratorBereichs zu füllen. Bei einigen übergeordneten Layoutelementen kann der bereich, der für den BulletDecorator Inhalt definiert ist, erweitern Child Bullet. Wenn es BulletDecorator sich beispielsweise um das einzelne untergeordnete Element einer Zelle in einem Grid Steuerelement handelt, gilt die Eigenschaft für die Background gesamte Zelle. Dies tritt auf, da der Inhalt in einer Grid Zelle standardmäßig in allen Richtungen gestreckt wird, um die Zelle zu füllen. Wenn Sie die Eigenschaft jedoch für den BulletDecoratorWert festlegen, wirkt sich die Background VerticalAlignment Eigenschaft Center nur auf den tatsächlichen Inhaltsbereich des Objekts BulletDecoratoraus. Alternativ können Sie das BulletDecorator Element in ein Panel Element einschließen.

Informationen zur Abhängigkeitseigenschaft

Bezeichnerfeld BackgroundProperty
Metadateneigenschaften auf true festgelegt AffectsRender, SubPropertiesDoNotAffectRender

Gilt für

Siehe auch