Compartir a través de


Point Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Represents an x- and y-coordinate pair in two-dimensional space. Can also represent a logical point for certain property usages.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Structure Point _
    Implements IFormattable
public struct Point : IFormattable
<Point .../>
<object property="X,Y"/>
-or
<object property="X Y"/>

XAML Values

  • X
    The x-coordinate component of this Point.

  • Y
    The y-coordinate component of this Point.

  • Either a space or a comma can be used as the delimiter. . See "Point Values in XAML" heading in Remarks below.

  • Some XAML usages use the Point type to represent a logical point, rather than a point in a pixel coordinate space. In this case, the values of X and Y are expected to be floating-point values between 0 and 1 inclusive. See "Logical Points" heading in Remarks below.

The Point type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows Phone Point Initializes a Point structure that contains the specified values.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone X Gets or sets the X-coordinate value of this Point structure.
Public propertySupported by Silverlight for Windows Phone Y Gets or sets the Y-coordinate value of this Point.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified object is a Point and whether it contains the same values as this Point. (Overrides ValueType.Equals(Object).)
Public methodSupported by Silverlight for Windows Phone Equals(Point) Compares two Point structures for equality.
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Returns the hash code for this Point. (Overrides ValueType.GetHashCode().)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ToString() Creates a String representation of this Point. (Overrides ValueType.ToString().)
Public methodSupported by Silverlight for Windows Phone ToString(IFormatProvider) Creates a String representation of this Point.

Top

Operators

  Name Description
Public operatorStatic memberSupported by Silverlight for Windows Phone Equality Compares two Point structures for equality.
Public operatorStatic memberSupported by Silverlight for Windows Phone Inequality Compares two Point structures for inequality

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows Phone IFormattable.ToString Infrastructure. For a description of this member, see ToString.

Top

Remarks

Some (but not all) usages of the Point type in Silverlight specify location in the Silverlight content area coordinate space. Depending on the context, the location might be either in the overall Silverlight content area frame of reference for coordinates, or might be within the frame of reference for a specific element. X and Y for a Point can be non-integer values in terms of permitted values. See "Logical Points" section below for information on certain Point usages that expect and use non-integer values extensively.

Depending on the specific property where the Point is applied, X and Y can possibly be negative. Typically, this results in a Point definition that specifies a coordinate outside of the Silverlight content area, unless there is additional translation. Many properties, for example EllipseGeometry.RadiusX, will reject a Point with negative  X and Y.

Point is the type that is returned from a call to the GetPosition method used in mouse event handlers. Also, a Point is used for some properties such as To and From of a PointAnimation. A Point can also be used as the qualifier for performing a hit test.

NoteNote:

The programmatic upper limit for Point values is not PositiveInfinity, it is a lower number (approximately 1,000,000) that is enforced by the Silverlight native code.

Point Values in XAML

Point uses a type converter, such that XAML attributes that take a Point as their value can specify a Point as a formatted string. The type converter generates or references a Point value based on processing the string. The format of that string is an X,Y value pair. The delimiter between X and Y can be either a comma (plus optionally zero or more spaces), or one or more spaces. The common convention for points is to use a comma delimiter.

The comma used as X,Y separator in the type converter behavior when specified as a string can clash with cultural settings where the comma character is the decimal separator if a decimal value is entered as a string. For usages of a Point that are representing points in the absolute coordinate space (usages that are not a logical point), you generally should use integer values for X and Y. When specifying a Point attribute in XAML, use the period (.) for noninteger X or Y values of a Point, even if that is not the convention in either the culture being developed under, or the target culture of the application.

Point structures cannot be declared as resources in a ResourceDictionary.

Logical Points

Some usages of the Point type in Silverlight do not relate to coordinate frames of reference directly. Instead, these are logical points, where the value of X,Y are each expected to be between 0 and 1 inclusive. This is a major scenario for why the X,Y values can be floating-point values rather than restricted to integer values. The logical point values are used when specifying certain values that have an X and Y dimension, and the Point values are then mapped to a presentation or behavior where the actual coordinates for presentation or behavior might be specified by a different property. Examples of the logical point usage are the values of a KeySpline, which can be used to pace an animation, and some values of LinearGradientBrush and RadialGradientBrush while using the default RelativeToBoundingBox mode. A property of Point type that is a logical point mapping might invalidate values less than 0, or greater than 1, but this depends on the specific property.

JavaScript API Notes

In the JavaScript API for Silverlight, a Point has the limitation that not all properties that take a Point will maintain an object reference to a Point object where the properties can be manipulated. Instead, some properties are write-once, using a type converter on the initial input and only retaining an internal object, with no Point available for that value in the object model.

In the managed API for Silverlight, all properties of a Point are accessible.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference