Skip to main content
.NET Framework Class Library
ShapeFill Property

Gets or sets the Brush that specifies how the shape's interior is painted.

Namespace:   System.Windows.Shapes
Assembly:  PresentationFramework (in PresentationFramework.dll)
Syntax
Public Property Fill As [%$TOPIC/ms605418_en-us_VS_110_2_0_0_0_0%]
public [%$TOPIC/ms605418_en-us_VS_110_2_0_1_0_0%] Fill { get; set; }
public:
property [%$TOPIC/ms605418_en-us_VS_110_2_0_2_0_0%]^ Fill {
	[%$TOPIC/ms605418_en-us_VS_110_2_0_2_0_1%]^ get ();
	void set ([%$TOPIC/ms605418_en-us_VS_110_2_0_2_0_2%]^ value);
}
member Fill : [%$TOPIC/ms605418_en-us_VS_110_2_0_3_0_0%] with get, set

Property Value

Type: System.Windows.MediaBrush
A Brush that describes how the shape's interior is painted. The default is .
Examples

This example shows how to use the Fill property to set the background color of an Ellipse element.

<Page  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel>
    <Ellipse Fill="Red" Width="100" Height="100" />
  </StackPanel>
</Page>

Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Shapes

Namespace SDKSample
	Partial Public Class SetBackgroundColorOfShapeExample
		Inherits Page
		Public Sub New()
			' Create a StackPanel to contain the shape.
			Dim myStackPanel As New StackPanel()

			' Create a red Ellipse.
			Dim myEllipse As New Ellipse()

			' Create a SolidColorBrush with a red color to fill the 
			' Ellipse with.
			Dim mySolidColorBrush As New SolidColorBrush()

			' Describes the brush's color using RGB values. 
			' Each value has a range of 0-255.
			mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0)
			myEllipse.Fill = mySolidColorBrush
			myEllipse.StrokeThickness = 2
			myEllipse.Stroke = Brushes.Black

			' Set the width and height of the Ellipse.
			myEllipse.Width = 200
			myEllipse.Height = 100

			' Add the Ellipse to the StackPanel.
			myStackPanel.Children.Add(myEllipse)

			Me.Content = myStackPanel
		End Sub

	End Class
End Namespace
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SDKSample
{
    public partial class SetBackgroundColorOfShapeExample : Page
    {
        public SetBackgroundColorOfShapeExample()
        {
            // Create a StackPanel to contain the shape.
            StackPanel myStackPanel = new StackPanel();

            // Create a red Ellipse.
            Ellipse myEllipse = new Ellipse();

            // Create a SolidColorBrush with a red color to fill the  
            // Ellipse with.
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            // Describes the brush's color using RGB values.  
            // Each value has a range of 0-255.
            mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
            myEllipse.Fill = mySolidColorBrush;
            myEllipse.StrokeThickness = 2;
            myEllipse.Stroke = Brushes.Black;

            // Set the width and height of the Ellipse.
            myEllipse.Width = 200;
            myEllipse.Height = 100;

            // Add the Ellipse to the StackPanel.
            myStackPanel.Children.Add(myEllipse);

            this.Content = myStackPanel;
        }

    }
}

More Code

How to: Paint an Area with a Solid ColorTo paint an area with a solid color, you can use a predefined system brush, such as Red or Blue, or you can create a new SolidColorBrush and describe its Color using alpha, red, green, and blue values. In XAML, you may also paint an area with a solid color by using hexidecimal notation.
How to: Paint an Area with an ImageThis example shows how to use the ImageBrush class to paint an area with an image. An ImageBrush displays a single image, which is specified by its ImageSource property.
How to: Make a UIElement Transparent or Semi-TransparentThis example shows how to make a UIElement transparent or semi-transparent. To make an element transparent or semi-transparent, you set its Opacity property. A value of 0.0 makes the element completely transparent, while a value of 1.0 makes the element completely opaque. A value of 0.5 makes the element 50% opaque, and so on. An element's Opacity is set to 1.0 by default.
How to: Animate a Property Without Using a StoryboardThis example shows one way to apply an animation to a property without using a Storyboard.
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.