{"record":{"id":"c610685972bc2a74","repo":"dotnet/wpf","slug":"sr-invalidstyluspointproperty","errorCode":null,"errorMessage":"SR.InvalidStylusPointProperty","messagePattern":"SR\\.InvalidStylusPointProperty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPoint.cs","lineNumber":292,"sourceCode":"            }\n            else if (stylusPointProperty.Id == StylusPointPropertyIds.Y)\n            {\n                return (int)_y;\n            }\n            else if (stylusPointProperty.Id == StylusPointPropertyIds.NormalPressure)\n            {\n                StylusPointPropertyInfo info =\n                    this.Description.GetPropertyInfo(StylusPointProperties.NormalPressure);\n\n                int max = info.Maximum;\n                return (int)(_pressureFactor * (float)max);\n            }\n            else\n            {\n                int propertyIndex = this.Description.GetPropertyIndex(stylusPointProperty.Id);\n                if (-1 == propertyIndex)\n                {\n                    throw new ArgumentException(SR.InvalidStylusPointProperty, nameof(stylusPointProperty));\n                }\n                if (stylusPointProperty.IsButton)\n                {\n                    //\n                    // we get button data from a single int in the array\n                    //\n                    int buttonData = _additionalValues[_additionalValues.Length - 1];\n                    int buttonBitPosition = this.Description.GetButtonBitPosition(stylusPointProperty);\n                    int bit = 1 << buttonBitPosition;\n                    if ((buttonData & bit) != 0)\n                    {\n                        return 1;\n                    }\n                    else\n                    {\n                        return 0;\n                    }\n                }","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPoint.cs#L274-L310","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check point.Description.HasProperty(stylusPointProperty) before calling GetPropertyValue.","Enumerate point.Description.GetStylusPointProperties() to find which properties are actually available.","Catch ArgumentException and treat the property as absent when descriptions may vary by device."],"exampleFix":"// before\nvar v = point.GetPropertyValue(StylusPointProperties.XTiltOrientation);\n// after\nif (point.Description.HasProperty(StylusPointProperties.XTiltOrientation))\n{\n    var v = point.GetPropertyValue(StylusPointProperties.XTiltOrientation);\n}","handlingStrategy":"validation","validationCode":"if (point.Description.HasProperty(prop))\n{\n    var v = point.GetPropertyValue(prop);\n}","typeGuard":"static bool HasProperty(StylusPoint p, StylusPointProperty prop) => p.Description.HasProperty(prop);","tryCatchPattern":"try { var v = point.GetPropertyValue(prop); }\ncatch (ArgumentException) { /* property not in description; use default */ }","preventionTips":["Always check Description.HasProperty first","Enumerate GetStylusPointProperties to discover available data","Handle device-specific property differences gracefully"],"tags":["wpf","stylus","argumentexception","property-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}