Control.Background Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a brush that provides the background of the control.
public:
property Brush ^ Background { Brush ^ get(); void set(Brush ^ value); };
Brush Background();
void Background(Brush value);
public Brush Background { get; set; }
var brush = control.background;
control.background = brush;
Public Property Background As Brush
<control Background="{StaticResource resourceName}"/>
- or -
<control Background="colorString"/>
- or -
<control>
<control.Background>singleBrush</control.Background>
</control>
The brush that provides the background of the control. The default is null, (a null brush) which is evaluated as Transparent for rendering.
Each control might apply this property differently based on its visual template. This property only affects a control whose template uses the Background property as an input for the template's UI properties. On other controls, this property has no effect. Typically, a control uses a {TemplateBinding} markup extension to bind its Background value to the Background of a Panel that is the root element of the control template; for example, to Grid.Background
. For more info about visual templates and control templating, see Styling controls or the reference page for the Template property.
Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background, Foreground, and BorderBrush. For more info, see the Light-weight styling section of the XAML styles article.
Product | Versions |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |