Windows Dev Center

Point structure

Represents x- and y-coordinate values that define a point in a two-dimensional plane.

Syntax


Public Structure Point


<object property="X,Y"/>
-or
<object property="X Y"/>

XAML Values

X

The x-coordinate component of the Point value.

Y

The y-coordinate component of the Point value.

Members

The Point structure has these types of members:

Constructors

The Point structure has these constructors.

ConstructorDescription
Point [C#, VB]Initializes a Point structure that contains the specified values.
Point [C++, JavaScript]Initializes a Point structure that contains the specified values.

 

Fields

The Point structure has these fields.

FieldData typeDescription
X | x [C++, JavaScript]

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The horizontal position of the point.

Y | y [C++, JavaScript]

Number [JavaScript] | System.Single [.NET] | float32 [C++]

The vertical position of the point.

 

Methods

The Point structure has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Equals(Object) [C#, VB]Determines whether the specified object is equal to a Point.
Equals(Point) [C#, VB]Compares two Point structures for equality.
GetHashCode [C#, VB]Gets a hash code for this object.
ToString [C#, VB]Converts a Point to a String representation.
ToString(IFormatProvider) [C#, VB]Creates a String representation of this Point.

 

Operators

The Point structure has these operators.

OperatorDescription
Equality Compares two Point structures for equality.
Inequality Compares two Point structures for inequality.

 

Properties

The Point structure has these properties.

PropertyAccess typeDescription

X

Read/writeGets or sets the X-coordinate value of this Point.

Y

Read/writeGets or sets the Y-coordinate value of this Point.

 

Remarks

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.

JavaScript:  In JavaScript, a Point is an object with two data properties: x and y. Other than x and y, the remaining APIs listed here in the Point members lists (or shown in the table of contents) don't apply to JavaScript programming.

Notes on XAML syntax

Point values are used extensively for graphics properties and similar UI-related properties throughout the XAML vocabulary for Windows Runtime apps.

Either a space or a comma can be used as the delimiter between X and Y values. The common convention for coordinate points is to use a comma delimiter.

Point structures cannot be declared as resources in a ResourceDictionary. A potential workaround is to use an x:String resource and then inject it into a string that's parsed with XamlReader.Load.

Some XAML usages use the Point type to represent a logical point. See "Logical Points" in Remarks.

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. .NET supports this functionality through the System.Runtime.WindowsRuntime.dll interop assembly that's shipped as part of .NET for Windows Runtime apps. C++/CX supports it through the language-specific platform.winmd metadata and the runtime behavior it represents.

If you are programming with C++ using the Windows Template Runtime Library (WRL), then only the data member fields exist as members of Point, and you cannot use the utility methods or properties listed in the members table. WRL code can access similar utility methods that are available from the PointHelper static class. For more info on WRL, see WRL Integration.

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 and Y 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 and Y 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 negative X or Y 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 of X and Y are each expected to be between 0 and 1 inclusive. This is one reason why the X and Y 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 of Animation.KeySpline (paces an animation), the RenderTransformOrigin of a UIElement, and the GradientStop.Offset values for a LinearGradientBrush.

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 APIs

The graphics elements used for defining a XAML UI often use Point-value properties to declare their characteristics. For example, an EllipseGeometry uses a Point value to set its Center property.

The graphics elements use one of two models. Some of the graphics elements are derived from FrameworkElement. These elements have a defined rendering behavior when placed in a UI and when element properties are assigned. Examples of this type of element are Rectangle and all the other types in the Windows.UI.Xaml.Shapes namespace. Other graphics elements don't derive from FrameworkElement, 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 compose Path.Data, such as LineSegment, often have a Point-value property.

Some graphics elements use multiple Point values represented in a single property. These properties use the PointCollection type. Any Windows Runtime property that takes a PointCollection supports a XAML syntax that parses the attribute string to get X and Y values for multiple points. An example of a graphics property that uses PointCollection is Polygon.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 a Pointer 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 APIs such as GetCurrentPoint and GetPosition 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, see Quickstart: Pointers.

XAML UI development also has a concept known as hit 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 of FindElementsInHostCoordinates use a Point input parameter, as does FindSubElementsForTouchTargeting. For more info, see Responding to mouse input.

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 the x and y values of a Point. Structures can't support dependency properties. Use the PointAnimation type for from-to animations, or use PointAnimationUsingKeyFrames derived types for key-frame animation behavior. For more info on how to animate a Point value and how animations work in XAML UI, see Storyboarded animations.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.FoundationContract, introduced version 1.0

Namespace

Windows.Foundation
Windows::Foundation [C++]

Metadata

Windows.Foundation.FoundationContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.Foundation
Windows::Foundation [C++]

Metadata

Windows.winmd

Attributes

[Version(0x06020000)]

See also

PointAnimation
PointCollection
Quickstart: Pointers
Quickstart: Drawing shapes

 

 

Show:
© 2015 Microsoft