Panel.Background 屬性

定義

取得或設定用來填滿 Brush 框線間之區域的 Panel

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

屬性值

Brush。 預設值為 null

範例

下列範例會將 BackgroundGrid 設定為 RadialGradientBrush

<Grid>
  <Grid.Background>
    <RadialGradientBrush 
        GradientOrigin="0.5,0.5" 
        Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
      <RadialGradientBrush.GradientStops>
        <GradientStop Color="Yellow" Offset="0" />
        <GradientStop Color="Red" Offset="0.25" />
        <GradientStop Color="Blue" Offset="0.75" />
        <GradientStop Color="Green" Offset="1" />
      </RadialGradientBrush.GradientStops>
    </RadialGradientBrush>
  </Grid.Background>
</Grid>

備註

Panel 如果未 Background 定義 ,元素就不會收到滑鼠或手寫筆事件。 如果您需要處理滑鼠或手寫筆事件,但不想使用 的背景 Panel ,請使用 Transparent

相依性屬性資訊

識別碼欄位 BackgroundProperty
中繼資料屬性設定為 true AffectsRender, SubPropertiesDoNotAffectRender

適用於

另請參閱