BulletDecorator.Background 屬性

定義

取得或設定 BulletDecorator 控制項的背景色彩。

C#
public System.Windows.Media.Brush Background { get; set; }

屬性值

BulletChildBulletDecorator 的背景色彩。 預設為 null

範例

下列範例示範如何在 控件上BulletDecorator設定 Background 屬性。

C#
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;
XAML
<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>

備註

屬性 BackgroundBrush 定義 ,以用來填滿 內的 BulletDecorator區域。 對於某些父版面配置元素,針對 定義的 BulletDecorator 區域可能會延伸到其 BulletChild 內容之外。 例如,如果 BulletDecorator 是控件中 Grid 儲存格的單一子系,則 Background 屬性會套用至整個儲存格。 這是因為儲存格中 Grid 的內容預設會以所有方向延展以填滿儲存格。 不過,如果您將 屬性設定為 ,則Background屬性只會影響 的實際內容區域BulletDecoratorBulletDecoratorVerticalAlignmentCenter 或者,您可以將 括 BulletDecorator 住 在 Panel 專案中。

相依性屬性資訊

標識元欄位 BackgroundProperty
設定為的元數據屬性 true AffectsRender, SubPropertiesDoNotAffectRender

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另請參閱