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:

Rectangle
Of these, Rectangle, Path and Ellipse are probably the most commonly used. Rectangle is often used as part of control composition for drawing a focus rectangle. Path is used for control glyphs, and also for PathIcon content. Ellipse is used for control compositions that include a circle, particularly in progress controls.

ClipPropertyClipPropertyClipPropertyClipProperty

CompositeModeCompositeModeCompositeModeCompositeMode

Gets or sets a property that declares alternate composition and blending modes for the element in its parent layout and window. This is relevant for elements that are involved in a mixed XAML / Microsoft DirectX UI.

FlowDirectionFlowDirectionFlowDirectionFlowDirection

Gets or sets the direction in which text and other UI elements flow within any parent element that controls their layout. This property can be set to either LeftToRight or RightToLeft. Setting FlowDirection to RightToLeft on any element sets the alignment to the right, the reading order to right-to-left and the layout of the control to flow from right to left.

Methods

Adds a routed event handler for a specified routed event, adding the handler to the handler collection on the current element. Specify handledEventsToo as true to have the provided handler be invoked even if the event is handled elsewhere.

Arrange(Rect)Arrange(Rect)Arrange(Rect)Arrange(Rect)

Positions child objects and determines a size for a UIElement. Parent objects that implement custom layout for their child elements should call this method from their layout override implementations to form a recursive layout update.

Remarks

This method gets an alpha mask from a XAML shape as a CompositionBrush that you can use as an input to composition shadows and effects. The alpha mask CompositionBrush has the same alignment and stretch property values that the source XAML shape applies to its rendered content so that you can use those values to correctly position shadows or effects relative to the XAML element.

InvalidateMeasureInvalidateMeasureInvalidateMeasureInvalidateMeasure

Measure(Size)Measure(Size)Measure(Size)Measure(Size)

Updates the DesiredSize of a UIElement. Typically, objects that implement custom layout for their layout children call this method from their own MeasureOverride implementations to form a recursive layout update.

OnApplyTemplateOnApplyTemplateOnApplyTemplateOnApplyTemplate

Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.

PointerPressedPointerPressedPointerPressedPointerPressed

PointerReleasedPointerReleasedPointerReleasedPointerReleased

Occurs when the pointer device that previously initiated a Press action is released, while within this element. Note that the end of a Press action is not guaranteed to fire a PointerReleased event; other events may fire instead. For more info, see Remarks.