Panel.Background 屬性

定義

取得或設定填滿面板內容區域的 Brush

public:
 property Brush ^ Background { Brush ^ get(); void set(Brush ^ value); };
Brush Background();

void Background(Brush value);
public Brush Background { get; set; }
var brush = panel.background;
panel.background = brush;
Public Property Background As Brush
<panel Background="{StaticResource resourceName}"/>
- or -
<panel Background="colorString"/>
- or -
<panel>
  <panel.Background>singleBrush</panel.Background>
</panel>

屬性值

填滿面板內容區域的筆刷。 默認值為 null, (null 筆刷) 評估為 透明 以進行轉譯。

備註

如果 Children 集合中的元素具有任何定義區域的透明度或 Null 筆刷,面板衍生面板的背景值會顯示在內部區域下方。 其會顯示在子系邊界區域中,任何子元素有影響其位置的非零 Margin 的情況。 不論邊界為何,任何子專案的版面配置位置之間也可見,不過這可以取決於面板實作其版面配置行為的方式。 例如,在 Canvas 中,內容區域中沒有絕對位置元素的任何像素都會顯示面板背景筆刷。

如果您使用 GridStackPanel 之類的 Panel 類別做為控件範本的根元素,使用 {TemplateBinding} 標記延伸將面板的背景系結至範本父系的 Control.Background 屬性, (使用範本的控件類別) 。

適用於

另請參閱