Point structure

Applies to Windows and Windows Phone

Represents an ordered pair of x- and y-coordinates 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.

Attributes

[Version(0x06020000)]

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 Pointvalue.

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

Notes on XAML syntax

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

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

Point structures cannot be declared as resources in a ResourceDictionary.

Some XAML usages use the Point type to represent a logical point. See "Logical Points" section 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.

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.

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 in some cases.

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 Store app using C++, C#, or Visual Basic APIs 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 a major scenario for why the X and Y values can be floating-point values rather than being restricted to integer values. The logical point values are interpreted such that the run-time coordinates for presentation or behavior might be specified or modified by a different property or setting. Or sometimes the points express information that doesn't relate to coordinate space at all. Examples of the logical point concept 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 this behavior depends on the specific property. Value constraints are typically noted in the reference pages for individual properties rather than on the value.

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. 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. These properties also support a XAML syntax that parses the attribute string to get X and Y values for multiple points. An example of a graphics element property that uses PointCollection is Polygon.Points.

Point values from XAML input events and for 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 that frame of reference. For input events the frame of reference is the main app window, not the overall screen. This enables a consistent frame of reference in case the app is in snapped view. 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 in an individual control. For more info, see Quickstart: Pointers.

XAML UI also has a concept known as hit testing, where you can use utility methods to test how input events would be sourced if the user were to perform a pointer action in a particular coordinate location of the UI. For example, 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 and that is implemented as a dependency property. Point has its own animation support because it's not possible to individually animate the x and y values of a Point, because 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, see Storyboarded animations.

Requirements

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
Platform.winmd

Assembly

System.Runtime.WindowsRuntime.dll

See also

PointAnimation
PointCollection
Quickstart: Pointers
Quickstart: Drawing shapes

 

 

Show:
© 2014 Microsoft