dotnet/wpf · error · ArgumentException

SR.InvalidStylusPointProperty

Error message

SR.InvalidStylusPointProperty

What it means

StylusPoint.GetPropertyValue throws ArgumentException when the supplied StylusPointProperty is not present in the point's StylusPointDescription; the description's property index lookup returns -1. Every property queried must be declared by the description the point was created with.

Solutions

  1. Check point.Description.HasProperty(stylusPointProperty) before calling GetPropertyValue.
  2. Enumerate point.Description.GetStylusPointProperties() to find which properties are actually available.
  3. Catch ArgumentException and treat the property as absent when descriptions may vary by device.

Example fix

// before
var v = point.GetPropertyValue(StylusPointProperties.XTiltOrientation);
// after
if (point.Description.HasProperty(StylusPointProperties.XTiltOrientation))
{
    var v = point.GetPropertyValue(StylusPointProperties.XTiltOrientation);
}
Defensive patterns

Strategy: validation

Validate before calling

if (point.Description.HasProperty(prop))
{
    var v = point.GetPropertyValue(prop);
}

Type guard

static bool HasProperty(StylusPoint p, StylusPointProperty prop) => p.Description.HasProperty(prop);

Try / catch

try { var v = point.GetPropertyValue(prop); }
catch (ArgumentException) { /* property not in description; use default */ }

Prevention

When it happens

Trigger: Calling point.GetPropertyValue(someProperty) with a property whose Id is not in point.Description (e.g. a property from a different tablet or a made-up StylusPointProperty).

Common situations: Reading a custom property (like tilt or a vendor-specific property) that the current device's description does not declare, or querying a point reformatted to a reduced description.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/c610685972bc2a74. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPoint.cs:292

            }
            else if (stylusPointProperty.Id == StylusPointPropertyIds.Y)
            {
                return (int)_y;
            }
            else if (stylusPointProperty.Id == StylusPointPropertyIds.NormalPressure)
            {
                StylusPointPropertyInfo info =
                    this.Description.GetPropertyInfo(StylusPointProperties.NormalPressure);

                int max = info.Maximum;
                return (int)(_pressureFactor * (float)max);
            }
            else
            {
                int propertyIndex = this.Description.GetPropertyIndex(stylusPointProperty.Id);
                if (-1 == propertyIndex)
                {
                    throw new ArgumentException(SR.InvalidStylusPointProperty, nameof(stylusPointProperty));
                }
                if (stylusPointProperty.IsButton)
                {
                    //
                    // we get button data from a single int in the array
                    //
                    int buttonData = _additionalValues[_additionalValues.Length - 1];
                    int buttonBitPosition = this.Description.GetButtonBitPosition(stylusPointProperty);
                    int bit = 1 << buttonBitPosition;
                    if ((buttonData & bit) != 0)
                    {
                        return 1;
                    }
                    else
                    {
                        return 0;
                    }
                }

View on GitHub (pinned to 81131a70a4)