BulletDecorator.Background Właściwość

Definicja

Pobiera lub ustawia kolor tła kontrolki BulletDecorator .

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

Wartość właściwości

Brush

Kolor tła elementu Bullet i Child elementu BulletDecorator. Wartość domyślna to null.

Przykłady

W poniższych przykładach pokazano, jak ustawić Background właściwość w kontrolce BulletDecorator .

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>

Uwagi

Właściwość Background definiuje Brush element , który ma być używany do wypełniania obszaru w obiekcie BulletDecorator. W przypadku niektórych elementów układu nadrzędnego obszar zdefiniowany dla elementu BulletDecorator może wykraczać poza jego Bullet zawartość i Child jego zawartość. Jeśli na przykład BulletDecorator element jest pojedynczym elementem podrzędnym komórki w kontrolce Grid , Background właściwość ma zastosowanie do całej komórki. Dzieje się tak, ponieważ zawartość w Grid komórce jest domyślnie rozciągana we wszystkich kierunkach, aby wypełnić komórkę. Jeśli jednak dla właściwości ustawiono VerticalAlignment wartość , Background właściwość Center BulletDecoratorma wpływ tylko na rzeczywisty obszar zawartości obiektu BulletDecorator. Alternatywnie można ująć element BulletDecorator w Panel element.

Informacje dotyczące właściwości zależności

Pole identyfikatora BackgroundProperty
Właściwości metadanych ustawione na true AffectsRender, SubPropertiesDoNotAffectRender

Dotyczy

Zobacz też