Поделиться через


BulletDecorator.Background Свойство

Определение

Возвращает или задает цвет фона для элемента управления 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

Значение свойства

Цвет фона для Bullet и Child элемента BulletDecorator. Значение по умолчанию — null.

Примеры

В следующих примерах показано, как задать Background свойство для 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>

Комментарии

Свойство Background определяет объект , используемый Brush для заполнения области в BulletDecorator. Для некоторых родительских элементов макета область, определенная для BulletDecorator , может выйти за пределы его Bullet содержимого и Child . Например, если BulletDecorator является единственным дочерним элементом ячейки в элементе GridBackground управления, свойство применяется ко всей ячейке. Это происходит потому, что содержимое ячейки Grid по умолчанию растягивается во всех направлениях для заполнения ячейки. Однако если для свойства задано значение VerticalAlignmentCenterBulletDecorator, Background свойство влияет только на фактическую область содержимого BulletDecoratorобъекта . Кроме того, можно заключить BulletDecorator в Panel элемент .

Сведения о свойстве зависимостей

Поле идентификатора BackgroundProperty
Для свойств метаданных задано значение true AffectsRender, SubPropertiesDoNotAffectRender

Применяется к

См. также раздел