Compartilhar via


BulletDecorator.Background Propriedade

Definição

Obtém ou define a cor da tela de fundo para um controle 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

Valor da propriedade

Brush

A cor da tela de fundo para o Bullet e Child de um BulletDecorator. O padrão é null.

Exemplos

Os exemplos a seguir mostram como definir a Background propriedade em um BulletDecorator controle.

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>

Comentários

A Background propriedade define o Brush uso para preencher a área dentro do BulletDecorator. Para alguns elementos de layout pai, a área definida para o BulletDecorator pode se estender além de seu Bullet conteúdo.Child Por exemplo, se o BulletDecorator filho único de uma célula em um Grid controle, a Background propriedade se aplicará a toda a célula. Isso ocorre porque o conteúdo em uma Grid célula é estendido em todas as direções para preencher a célula, por padrão. No entanto, se você definir a VerticalAlignment propriedade para a BulletDecorator, a Background propriedade afetará apenas a área de conteúdo real da BulletDecoratorCenter . Como alternativa, você pode colocar o BulletDecorator elemento em um Panel elemento.

Informações da propriedade de dependência

Campo identificador BackgroundProperty
Propriedades de metadados definidas como true AffectsRender, SubPropertiesDoNotAffectRender

Aplica-se a

Confira também