PressureFactor Property
Collapse the table of content
Expand the table of content

StylusPoint.PressureFactor Property

Gets or sets a value between 0 and 1 that reflects the amount of pressure the stylus applies to the digitizer's surface when the StylusPoint is created.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public float PressureFactor { get; set; }
/** @property */
public float get_PressureFactor ()

/** @property */
public void set_PressureFactor (float value)

public function get PressureFactor () : float

public function set PressureFactor (value : float)

<object PressureFactor="float" .../>

Property Value

Value between 0 and 1 that reflects the amount of pressure the stylus applies to the digitizer's surface when the StylusPoint is created.

Exception typeCondition


The PressureFactor property is set to a value less than 0 or greater than 1.

The value of the PressureFactor property is expressed as a value between 0 and 1. A value of 0 indicates that no pressure is applied, while a value of 1 indicates that the maximum amount of pressure is applied. A value of 0.5 indicates that 50% of the maximum pressure is applied, and so on.

The following example uses the PressureFactor property to retrieve and display the pressure for each StylusPoint in a StylusPointCollection called points. This example assumes that there is a TextBlock called packetOutput.

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

        ReadOnlyCollection<StylusPointPropertyInfo> properties = 
        // 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));


        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";

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

Community Additions

© 2016 Microsoft