Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 4.29 KB

shape.md

File metadata and controls

46 lines (31 loc) · 4.29 KB
-api-id -api-type
T:Windows.UI.Xaml.Shapes.Shape
winrt class

Windows.UI.Xaml.Shapes.Shape

-description

Provides a base class for shape elements, such as Ellipse, Polygon, and Rectangle.

-remarks

Shape defines several properties that are shared by all the Shape derived classes. The most commonly used properties are Fill, Stroke, and StrokeThickness. Stroke uses a Brush to draw the outline of the shape, and Fill uses a Brush to draw the interior. For more info on how to use the Shape derived classes in XAML UI, see Draw shapes.

Shape also derives from FrameworkElement and inherits various properties from that class. Those properties include Height and Width. For most other FrameworkElement derived types, setting Height and Width is the primary way to specify that element's dimensions in UI (although you often would leave them as "Auto" to take advantage of adaptive layout). But not all of the Shape classes use Height or Width to specify their dimensions, and instead use specific properties that might define a set of points. In this case a Height or Width is calculated for layout, but you shouldn't attempt to set the Height or Width. See the remarks or descriptions in specific Shape derived classes for more info.

Because the Shape derived classes are UI elements they can be used as content for containers such as controls and panels. They have practical presence in the UI; for example they are hit-testable with input events, they report desired size for layout, and so on. There are other graphics definition classes for XAML that aren't UI elements. These mostly exist in the Windows.UI.Xaml.Media namespace. Examples of such graphics classes are the Geometry types, PathFigure types and PathSegment types.

Shape derived classes

Shape is the parent class for several immediately derived classes that define primitive shapes for use as UI elements:

Version history

Windows version SDK version Value added
1607 14393 GetAlphaMask

-examples

For example code of how to use Shape derived classes such as Rectangle and Path, see XAML vector-based drawing sample.

-see-also

FrameworkElement, XAML vector-based drawing sample, Draw shapes