This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents x- and y-coordinate values that define a point in a two-dimensional plane.
public value class Point/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]struct Point[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]public struct Pointvar point = {x : /* Your value */,y : /* Your value */}Public Structure Point<object property="X,Y"/>-or<object property="X Y"/>| Requirements | Description |
|---|---|
| Device family | Windows 10 (introduced in 10.0.10240.0) |
| API contract | Windows.Foundation.FoundationContract (introduced in v1.0) |
A Point value sometimes represents a coordinate space in the plane of the main window of an app, but there are other possible interpretations of Point values that can vary, depending on the property that uses the Point value.
#"windows.ui.xaml.resourcedictionary?view=winrt-26100" data-linktype="relative-path">ResourceDictionary. A potential workaround is touse an x:String resource and then inject it into a string that's parsed withXamlReader.Load.
Some XAML usages use the Point type to represent alogical point. See "Logical Points" in Remarks.
Point values and how they are interpreted by properties
Some (but not all) usages of the Point type specify location in a coordinate space. Depending on the context, the location might be in a content area's frame of reference, or might be within the frame of reference for a specific layout element.
X andY for a Point can be non-integer values. However, this can introduce the possibility of sub-pixel rendering, which can change colors and anti-alias any straight line along the sub-pixel edge. That's how the XAML rendering engine treats sub-pixel boundaries. So for best results, use integer values when declaring coordinates and shapes that are used for UI positioning and rendering.
X andY for a Point can be negative in some cases. Typically, this results in a Point that specifies a coordinate that is deliberately outside the frame of reference, unless there is additional translation. However, some XAML properties reject a Point with negativeX orY as an invalid value. Value constraints are typically noted in the reference pages for properties.
Logical points
Some usages of the Point type in Windows Runtime apps do not relate to coordinate frames of reference directly. Instead, these are logical points, where the value ofX andY are each expected to be between 0 and 1 inclusive. This is one reason why theX andY values support floating-point values rather than being constrained to integer values. Logical point values are interpreted by a context: the ultimate presentation or behavior might be specified or modified by a different property or setting. Sometimes the points express information that doesn't relate to coordinate space at all. Examples of the logical point concept in application are the values ofAnimation.KeySpline (paces an animation), theRenderTransformOrigin of aUIElement, and theGradientStop.Offset values for aLinearGradientBrush.
A Point-value property that is a logical point usage may invalidate values less than 0, or greater than 1, but the specifics vary by property. Value constraints are typically noted in the reference pages for individual properties, rather than here in the Point reference.
Point values and XAML graphics API
The graphics elements used for defining a XAML UI often use Point-value properties to declare their characteristics. For example, anEllipseGeometry uses a Point value to set itsCenter property.
The graphics elements use one of two models. Some of the graphics elements are derived fromFrameworkElement. These elements have a defined rendering behavior when placed in a UI and when element properties are assigned. Examples of this type of element areRectangle and all the other types in theWindows.UI.Xaml.Shapes namespace. Other graphics elements don't derive fromFrameworkElement, and don't have a rendering behavior of their own. Instead, these elements are composed to provide the value of a property on some other element that does have a rendering behavior. In other words, they're data for a more comprehensive graphics model. For example, the graphics elements you use to composePath.Data, such asLineSegment, often have a Point-value property.
Some graphics elements use multiple Point values represented in a single property. These properties use thePointCollection type. Any Windows Runtime property that takes aPointCollection supports a XAML syntax that parses the attribute string to getX andY values for multiple points. An example of a graphics property that usesPointCollection isPolygon.Points.
Point values from XAML input events, and hit testing
A Point value is returned by the event data for certain input events. For example,GetCurrentPoint provides a coordinate value of where aPointer event occurred in app UI. Generally speaking, these Point values refer to a certain frame of coordinate reference and it is important to know what that frame of reference represents. For input events, the frame of reference by default is the main app window, not the overall screen/display. This enables a consistent frame of reference in case the window is moved or resized. Some API such asGetCurrentPoint andGetPosition also provide a way to translate to an element-specific frame of reference, which is useful when working with input events that are handled by an individual control. For more info, seeHandle pointer input.
XAML UI development also has a concept known ashit testing, where you can use utility methods to test how input events would report info if the user were to perform a pointer action in a particular coordinate location of the UI. To support the hit testing concept, 2 signatures ofFindElementsInHostCoordinates use a Point input parameter, as doesFindSubElementsForTouchTargeting. For more info, seeMouse interactions.
Animating Point values
The Windows Runtime provides a means to animate the values of any property that uses a Point as a value, so long as that property is implemented as a dependency property. Point has its own animation support type because it's not possible to individually animate thex andy values of a Point. Structures can't support dependency properties. Use thePointAnimation type forfrom-to animations, or usePointAnimationUsingKeyFrames derived types for key-frame animation behavior. For more info on how to animate a Point value and how animations work in XAML UI, seeStoryboarded animations.
Projection and members of Point
If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or Visual C++ component extensions (C++/CX), then Point has non-data members available, and its data members are exposed as read-write properties, not fields. SeePoint in the .NET API Browser.
If you are programming withC++/WinRT or theWindows Runtime C++ Template Library (WRL), then only the data member fields exist as members of Point, and you cannot use the utility methods or properties of the .NET projection. C++ code can access similar utility methods that are available from thePointHelper static class.
This table shows the equivalent methods available in .NET and C++.
.NET (Point) C++ (PointHelper) Point(Double, Double) FromCoordinates(Single, Single) Applies to
See also
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?