Språk

BulletDecorator.Background Egenskap

Definition

Hämtar eller anger bakgrundsfärgen för en BulletDecorator kontroll.

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

Egenskapsvärde

Bakgrundsfärgen Bullet för och Child för en BulletDecorator. Standardvärdet är null.

Exempel

I följande exempel visas hur du ställer in egenskapen på Background en BulletDecorator kontroll.

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>

Kommentarer

Egenskapen Background definierar det Brush som ska användas för att fylla området i BulletDecorator. För vissa överordnade layoutelement kan det område som har definierats för BulletDecorator det sträcka sig bortom dess Bullet och Child innehållet. Om BulletDecorator till exempel är det enda underordnade i en cell i en Grid kontroll Background gäller egenskapen för hela cellen. Detta beror på att innehållet i en Grid cell sträcks ut i alla riktningar för att fylla cellen som standard. Men om du anger VerticalAlignment egenskapen till Center för BulletDecoratorBackground påverkar egenskapen endast det faktiska innehållsområdet i BulletDecorator. Du kan också omsluta BulletDecorator i ett Panel element.

Information om beroendeegenskap

Objekt Value
Identifierarfält BackgroundProperty
Metadataegenskaper inställda på true AffectsRender, SubPropertiesDoNotAffectRender

Gäller för

Se även