Skip to main content
 

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 Brush Fill { get; set; }
public:
property Brush^ Fill {
	Brush^ get();
	void set(Brush^ value);
}
member Fill : Brush with get, set
Public Property Fill As Brush

Property Value

Type:

A Brush that describes how the shape's interior is painted. The default is null.

Remarks
Dependency Property Information

Identifier field

FillProperty

Metadata properties set to true

, f

Examples

This example shows how to use the 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>
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;
        }

    }
}

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
Version Information
.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top