Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 3.17 KB

control_background.md

File metadata and controls

44 lines (33 loc) · 3.17 KB
-api-id -api-type
P:Microsoft.UI.Xaml.Controls.Control.Background
winrt property

Microsoft.UI.Xaml.Controls.Control.Background

-description

Gets or sets a brush that provides the background of the control.

-xaml-syntax

<control Background="{StaticResource resourceName}"/>
- or -
<control Background="colorString"/>
- or -
<control>
  <control.Background>singleBrush</control.Background>
</control>

-xaml-values

resourceName
resourceNameThe resource name (x:Key attribute value) of an existing XAML resource that defines a brush. This is the recommended way to specify Brush values in XAML if you have any intention of using the same colors or brushes in more than one part of your UI. See Remarks in Brush or ResourceDictionary and XAML resource references.
colorString
colorStringThe Color for a SolidColorBrush expressed as an attribute string. This can be a named color, an RGB value, or an ScRGB value. RGB or ScRGB may also specify alpha information. See the XAML Values section in Color.
singleBrush
singleBrushWithin opening and closing property elements, exactly one object element for an object that derives from Brush. This is typically one of the following classes: LinearGradientBrush, ImageBrush, SolidColorBrush.
## -property-value The brush that provides the background of the control. The default is **null**, (a null brush) which is evaluated as [Transparent](../microsoft.ui/colors_transparent.md) for rendering.

-remarks

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 Styling controls article.

-examples

-see-also

XAML brushes, Control.BorderBrush, Panel.Background