Provides a base class for shape elements, such as
Ellipse,
Polygon, and
Rectangle. This class is abstract.
Namespace: System.Windows.Shapes
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Visual Basic (Declaration)
<LocalizabilityAttribute(LocalizationCategory.None, Readability:=Readability.Unreadable)> _
Public MustInherit Class Shape
Inherits FrameworkElement
[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)]
public abstract class Shape : FrameworkElement
[LocalizabilityAttribute(LocalizationCategory::None, Readability=Readability::Unreadable)]
public ref class Shape abstract : public FrameworkElement
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */
public abstract class Shape extends FrameworkElement
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)
public abstract class Shape extends FrameworkElement
This class is abstract; see <a href="#inheritanceHierarchyToggle">Inheritance Hierarchy</a> for derived non-abstract classes usable in XAML.
This example shows you how to draw lines by using the Line element.
To draw a line, create a Line element. Use its X1 and Y1 properties to set its start point; and use its X2 and Y2 properties to set its end point. Finally, set its Stroke and StrokeThickness because a line without a stroke is invisible.
Setting the Fill element for a line has no effect, because a line has no interior.
The following example draws three lines inside a Canvas element.
<Canvas Height="300" Width="300">
<!-- Draws a diagonal line from (10,10) to (50,50). -->
<Line
X1="10" Y1="10"
X2="50" Y2="50"
Stroke="Black"
StrokeThickness="4" />
<!-- Draws a diagonal line from (10,10) to (50,50)
and moves it 100 pixels to the right. -->
<Line
X1="10" Y1="10"
X2="50" Y2="50"
StrokeThickness="4"
Canvas.Left="100">
<Line.Stroke>
<RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
<RadialGradientBrush.GradientStops>
<GradientStop Color="Red" Offset="0" />
<GradientStop Color="Blue" Offset="0.25" />
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Line.Stroke>
</Line>
<!-- Draws a horizontal line from (10,60) to (150,60). -->
<Line
X1="10" Y1="60"
X2="150" Y2="60"
Stroke="Black"
StrokeThickness="4"/>
</Canvas>
This example is part of a larger sample; for the complete sample, see Shape Elements Sample.
More Code
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Shapes.Shape
Derived Classes
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
.NET Framework
Supported in: 3.0