Geometry Class
Definition
Provides a base class for objects that define geometric shapes. Geometry objects can be used for clipping regions and as geometry definitions for rendering two-dimensional graphical data as a Path.
Equivalent WinUI class: Microsoft.UI.Xaml.Media.Geometry.
public ref class Geometry : DependencyObject
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Media.IGeometryFactory, Windows.Foundation.Metadata.CompositionType.Protected, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Media.IGeometryStatics, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
class Geometry : DependencyObject
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Media.IGeometryFactory, Windows.Foundation.Metadata.CompositionType.Protected, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Media.IGeometryStatics, 65536, "Windows.Foundation.UniversalApiContract")]
class Geometry : DependencyObject
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Media.IGeometryStatics, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Media.IGeometryFactory, Windows.Foundation.Metadata.CompositionType.Public, 65536, "Windows.Foundation.UniversalApiContract")]
class Geometry : DependencyObject
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Media.IGeometryFactory), Windows.Foundation.Metadata.CompositionType.Protected, 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Media.IGeometryStatics), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
public class Geometry : DependencyObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Media.IGeometryFactory), Windows.Foundation.Metadata.CompositionType.Protected, 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Media.IGeometryStatics), 65536, "Windows.Foundation.UniversalApiContract")]
public class Geometry : DependencyObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Media.IGeometryStatics), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Media.IGeometryFactory), Windows.Foundation.Metadata.CompositionType.Public, 65536, "Windows.Foundation.UniversalApiContract")]
public class Geometry : DependencyObject
Public Class Geometry
Inherits DependencyObject
- Inheritance
- Derived
- Attributes
Windows 10 requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
Remarks
For properties that take a Geometry, you need to specify a nonabstract derived type of Geometry, as an object element for XAML, or as a defined instance for code. For details, see reference pages for EllipseGeometry, GeometryGroup, LineGeometry, PathGeometry, or RectangleGeometry.
Geometries can be conceptualized as being "simple" or "complex". EllipseGeometry, LineGeometry, and RectangleGeometry are the simple geometries, which specify the geometrical shape as one element with basic coordinate or dimension properties. GeometryGroup and PathGeometry are the complex geometries. GeometryGroup combines other geometries that it holds as child objects. PathGeometry uses either a set of nested figure/segment path definition elements, or a compact string syntax that's usually output by designers, to describe a complex path for the geometry.
A Geometry does not entirely define its own rendering, in that it's not a UIElement itself and needs to be provided as some property value for a UIElement in order to cause a rendering effect. Typically, a Geometry is provided as data for a Path (which is a kind of Shape ).
The PathIcon.Data property takes a Geometry. In practice, you'd typically specify a PathGeometry for this, with its Figures property value expressed in the compact string syntax for a path.
GeometryCollection is a strongly typed collection for Geometry items. The GeometryGroup.Children property uses a GeometryCollection.
Geometry versus Shape
The Shape class has a Fill, Stroke, and other rendering properties that Geometry and its derived classes lack. The Shape class is a FrameworkElement and therefore participates in the layout system; its derived classes can be used as the content of any element that supports UIElement children. The Geometry class, on the other hand, simply defines the geometry as a graphics primitive, and cannot render itself. You could conceivably use Geometry as a property type for custom UI element properties where the basic graphics primitive expressions enabled by Geometry are useful as a definition.
Geometry for UIElement.Clip
To provide a value for the UIElement.Clip property in the Windows Runtime, you must specifically use a RectangleGeometry, not any Geometry derived type. If you're porting XAML or code from other XAML frameworks, see if you can change your UIElement.Clip to use RectangleGeometry. Otherwise, you might need to change the Z-order relationship and use techniques such as an overlay of an ImageBrush with a modified RenderTargetBitmap source that has alpha transparency for the "clipping" parts.
Geometry derived classes
Geometry is the parent class for several derived classes that define different categories of practical geometries:
- EllipseGeometry
- GeometryGroup - can be used to specify multiple geometries as Children
- LineGeometry
- PathGeometry - use this type for any geometry that can't be expressed by the other "simple" geometry types
- RectangleGeometry
Properties
Bounds |
Gets a Rect that specifies the axis-aligned bounding box of the Geometry. Equivalent WinUI property: Microsoft.UI.Xaml.Media.Geometry.Bounds. |
Dispatcher |
Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread. Equivalent WinUI property: Microsoft.UI.Xaml.DependencyObject.Dispatcher. (Inherited from DependencyObject) |
Empty |
Gets an empty geometry object. Equivalent WinUI property: Microsoft.UI.Xaml.Media.Geometry.Empty. |
StandardFlatteningTolerance |
Gets the standard tolerance used for polygonal approximation. Equivalent WinUI property: Microsoft.UI.Xaml.Media.Geometry.StandardFlatteningTolerance. |
Transform |
Gets or sets the Transform object applied to a Geometry. Equivalent WinUI property: Microsoft.UI.Xaml.Media.Geometry.Transform. |
TransformProperty |
Identifies the Transform dependency property. Equivalent WinUI property: Microsoft.UI.Xaml.Media.Geometry.TransformProperty. |