相关文章推荐
果断的毛豆  ·  Oracle 12c ...·  2 年前    · 
着急的回锅肉  ·  corda - When to add ...·  2 年前    · 
满身肌肉的山羊  ·  Python pandas ...·  2 年前    · 
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
<Run Background="LightGreen">Text run 1.</Run> <LineBreak/><Run Background="LightBlue">Text run 2.</Run> <LineBreak/><Run Background="LightYellow">Text run 3.</Run> </TextBlock>

下列範例示範如何以程式設計方式設定 Background 屬性。

TextBlock textBlock = new TextBlock(new Run("A bit of text content...")); textBlock.Background = Brushes.AntiqueWhite; textBlock.Foreground = Brushes.Navy; textBlock.FontFamily = new FontFamily("Century Gothic"); textBlock.FontSize = 12; textBlock.FontStretch = FontStretches.UltraExpanded; textBlock.FontStyle = FontStyles.Italic; textBlock.FontWeight = FontWeights.UltraBold; textBlock.LineHeight = Double.NaN; textBlock.Padding = new Thickness(5, 10, 5, 10); textBlock.TextAlignment = TextAlignment.Center; textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle; textBlock.Typography.SlashedZero = true; Dim textBlock As New TextBlock(New Run("A bit of text content...")) textBlock.Background = Brushes.AntiqueWhite textBlock.Foreground = Brushes.Navy textBlock.FontFamily = New FontFamily("Century Gothic") textBlock.FontSize = 12 textBlock.FontStretch = FontStretches.UltraExpanded textBlock.FontStyle = FontStyles.Italic textBlock.FontWeight = FontWeights.UltraBold textBlock.LineHeight = Double.NaN textBlock.Padding = New Thickness(5, 10, 5, 10) textBlock.TextAlignment = TextAlignment.Center textBlock.TextWrapping = TextWrapping.Wrap textBlock.Typography.NumeralStyle = FontNumeralStyle.OldStyle textBlock.Typography.SlashedZero = True

子項目上的任何 Background 設定會覆寫此最上層設定。

如需顯示可用預先定義筆刷色彩的表格,請參閱 Brushes

相依性屬性資訊