Share via


BulletDecorator.Background Propiedad

Definición

Obtiene o establece el color de fondo de un control 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 de propiedad

Brush

Color de fondo de Bullet y Child de BulletDecorator. De manera predeterminada, es null.

Ejemplos

En los ejemplos siguientes se muestra cómo establecer la Background propiedad en un BulletDecorator control .

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>

Comentarios

La Background propiedad define el Brush objeto que se va a usar para rellenar el área dentro de BulletDecorator. Para algunos elementos de diseño primarios, el área definida para puede BulletDecorator extenderse más allá de su Bullet contenido y Child . Por ejemplo, si BulletDecorator es el único elemento secundario de una celda de un Grid control, la Background propiedad se aplica a toda la celda. Esto ocurre porque el contenido de una Grid celda se extiende en todas las direcciones para rellenar la celda de forma predeterminada. Sin embargo, si establece la VerticalAlignment propiedad Center en para BulletDecorator, la Background propiedad solo afecta al área de contenido real de .BulletDecorator Como alternativa, puede incluir en BulletDecorator un Panel elemento .

Información sobre propiedades de dependencia

Campo identificador BackgroundProperty
Propiedades de metadatos establecidas en true AffectsRender, SubPropertiesDoNotAffectRender

Se aplica a

Consulte también