Panel.Background Właściwość

Definicja

Pobiera lub ustawia Brush element używany do wypełniania obszaru między obramowaniami obiektu 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

Wartość właściwości

Klasa Brush. Ta wartość domyślna to null.

Przykłady

W poniższym przykładzie ustawiono element Background na Grid wartość 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>

Uwagi

Panel elementy nie odbierają zdarzeń myszy ani rysika, jeśli nie zdefiniowano elementu Background . Jeśli musisz obsługiwać zdarzenia myszy lub stylus, ale nie chcesz tła dla elementu Panel, użyj polecenia Transparent.

Informacje dotyczące właściwości zależności

Pole identyfikatora BackgroundProperty
Właściwości metadanych ustawione na true AffectsRender, SubPropertiesDoNotAffectRender

Dotyczy

Zobacz też