語言

BulletDecorator.Background 屬性

定義

取得或設定控制點的 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

屬性值

與 的Bullet背景色。ChildBulletDecorator 預設值為 null。

範例

以下範例說明如何設定 Background 控制項上的 BulletDecorator 屬性。

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>

備註

屬性 Background 定義了 Brush 來填充 內的區域 BulletDecorator。 對於某些父版面元素,定義的 BulletDecorator 區域可能超出其 Bullet 與 Child 內容範圍。 例如,若 是 BulletDecorator 控制項中 Grid 某個格子的唯一子節點,則該 Background 性質適用於整個格子。 這是因為儲存格內的內容 Grid 預設會向各個方向拉伸以填滿整個儲存格。 然而,如果你將屬性設 VerticalAlignment 為 CenterBulletDecorator,該 Background 屬性只影響 的 BulletDecorator實際內容區域。 或者,你也可以把它 BulletDecorator 包在一個 Panel 元素裡。

相依財產資訊

Item 價值觀
識別碼欄位 BackgroundProperty
元資料屬性設為 true AffectsRender、SubPropertiesDoNotAffectRender

適用於

另請參閱