BulletDecorator.Background Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the background color for a BulletDecorator control.

Namespace:   System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)

public Brush Background { get; set; }

Property Value

Type: System.Windows.Media.Brush

The background color for the Bullet and Child of a BulletDecorator. The default is null.

The Background property defines the Brush to use to fill the area within the BulletDecorator. For some parent layout elements, the area that is defined for the BulletDecorator may extend beyond its Bullet and Child content. For example, if the BulletDecorator is the single child of a cell in a Grid control, the Background property applies to the whole cell. This occurs because the content in a Grid cell is stretched in all directions to fill the cell, by default. However, if you set the VerticalAlignment property to Center for the BulletDecorator, the Background property only affects the actual content area of the BulletDecorator. Alternatively, you can enclose the BulletDecorator in a Panel element.

The following examples show how to set the Background property on a BulletDecorator control.

BulletDecorator myBulletDecorator = new BulletDecorator();
Image myImage = new Image();
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.UriSource = new Uri(@"pack://application:,,/images/apple.jpg");
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;
<BulletDecorator  Grid.Row="1" Grid.Column="0" Margin="0,5,0,0"
                  VerticalAlignment="Center" Background="Yellow">
    <Image Source="images\apple.jpg"/>
    Foreground ="Purple">
    A Simple BulletDecorator

.NET Framework
Available since 3.0
Return to top