StylusPoint Structure

Represents a single data point collected from the digitizer and stylus.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public struct StylusPoint : IEquatable<StylusPoint>
public final class StylusPoint extends ValueType implements IEquatable<StylusPoint>
<StylusPoint .../>

A StylusPoint collects data when a user inputs ink using the digitizer. Because the information that a digitizer reports differs depending on the manufacture, the properties within a StylusPoint can vary. To determine whether a property is in the StylusPoint, call the HasProperty method. The Description property contains a StylusPointDescription that specifies which properties are in the StylusPoint. All StylusPoint objects contain properties that specify the (x, y) coordinates and pressure.

The following example gets the property names and values for each StylusPoint in a StylusPointCollection. This example assumes that there is a TextBlock called packetOutput.

    private void WriteStylusPointValues(StylusPointCollection points)
    {
        StylusPointDescription pointsDescription = points.Description;

        ReadOnlyCollection<StylusPointPropertyInfo> properties = 
            pointsDescription.GetStylusPointProperties();
        
        // Write the name and and value of each property in
        // every stylus point.
        StringWriter packetWriter = new StringWriter();
        packetWriter.WriteLine("{0} stylus points", points.Count.ToString());
        foreach (StylusPoint stylusPoint in points)
        {
            packetWriter.WriteLine("Stylus Point info");
            packetWriter.WriteLine("X: {0}", stylusPoint.X.ToString());
            packetWriter.WriteLine("Y: {0}", stylusPoint.Y.ToString());
            packetWriter.WriteLine("Pressure: {0}", stylusPoint.PressureFactor.ToString());

            // Get the property name and value for each StylusPoint.
            // Note that this loop reports the X, Y, and pressure values differantly than 
            // getting their values above.
            for (int i = 0; i < pointsDescription.PropertyCount; ++i)
            {
                StylusPointProperty currentProperty = properties[i];

                // GetStylusPointPropertyName is defined below and returns the
                // name of the property.
                packetWriter.Write("{0}: ", GetStylusPointPropertyName(currentProperty));
                packetWriter.WriteLine(stylusPoint.GetPropertyValue(currentProperty).ToString());
            }
            packetWriter.WriteLine();

        }

        packetOutput.Text = packetWriter.ToString();
    }

...

    // Use reflection to get the name of currentProperty.
    private string GetStylusPointPropertyName(StylusPointProperty currentProperty)
    {
        Guid guid = currentProperty.Id;

        // Iterate through the StylusPointProperties to find the StylusPointProperty
        // that matches currentProperty, then return the name.
        foreach (FieldInfo theFieldInfo
            in typeof(StylusPointProperties).GetFields())
        {
            StylusPointProperty property = (StylusPointProperty) theFieldInfo.GetValue(currentProperty);
            if (property.Id == guid)
            {
                return theFieldInfo.Name;
            }
        }
        return "Not found";
    }

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: