This topic has not yet been rated - Rate this topic

Shape.Fill Property

April 12, 2014

Gets or sets the Brush that specifies how to paint the interior of the shape.

Namespace:  System.Windows.Shapes
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
public Brush Fill { get; set; }
<object>
  <object.Fill>
    singleBrush
  </object.Fill>
</object>
<object Fill="colorString"/>

XAML Values

singleBrush

Within opening and closing property elements for object.Fill, exactly one object element for a class that derives from Brush. This is typically one of the following: LinearGradientBrush, RadialGradientBrush, ImageBrush, SolidColorBrush, or VideoBrush.

colorString

The 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 "XAML Attribute Syntax" section in the SolidColorBrush topic.

Property Value

Type: System.Windows.Media.Brush
A Brush that describes how the shape's interior is painted. The default is null. See Remarks.

Dependency property identifier field: FillProperty

For rendering, the null default value is interpreted as a Brush that has no color value, but renders as Transparent. A value of a null Brush has no hit-testable region, while a value of an actual brush with a color value of Transparent is hit-testable.

Setting the Fill for a line (Line or Polyline) has no effect, because a line has no interior. Use the Stroke and StrokeThickness properties for lines instead.

Some brush types (SolidColorBrush) support a XAML attribute syntax, whereas other brush types (ImageBrush, LinearGradientBrush, RadialGradientBrush) only support an object element syntax. This is why two versions of XAML syntax are shown for this property.

When animating a Fill, you must use indirect targeting. For instance, if you are animating the color of a SolidColorBrush that is the Fill of a Rectangle, the syntax would be <ColorAnimation ... Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" />.

The area where the Fill applies to a Path is potentially influenced by its geometry data's FillRule.

If a Fill is null (or not specified), there is no hit-testable region within the object.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.