{"record":{"id":"e011e218b8c76bdd","repo":"dotnet/wpf","slug":"sr-incompatiblestyluspointdescriptions-styluspointcollection","errorCode":null,"errorMessage":"SR.IncompatibleStylusPointDescriptions","messagePattern":"SR\\.IncompatibleStylusPointDescriptions","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointCollection.cs","lineNumber":204,"sourceCode":"                }\n\n                //this does not go through our protected virtuals\n                ((List<StylusPoint>)this.Items).Add(newPoint);\n            }\n        }\n\n        /// <summary>\n        /// Adds the StylusPoints in the StylusPointCollection to this StylusPointCollection\n        /// </summary>\n        /// <param name=\"stylusPoints\">stylusPoints</param>\n        public void Add(StylusPointCollection stylusPoints)\n        {\n            //note that we don't raise an exception if stylusPoints.Count == 0\n            ArgumentNullException.ThrowIfNull(stylusPoints);\n            if (!StylusPointDescription.AreCompatible(stylusPoints.Description,\n                                                        _stylusPointDescription))\n            {\n                throw new ArgumentException(SR.IncompatibleStylusPointDescriptions, nameof(stylusPoints));\n            }\n\n            // cache count outside of the loop, so if this SPC is ever passed\n            // we don't loop forever\n            int count = stylusPoints.Count;\n            for (int x = 0; x < count; x++)\n            {\n                StylusPoint stylusPoint = stylusPoints[x];\n                stylusPoint.Description = _stylusPointDescription;\n                //this does not go through our protected virtuals\n                ((List<StylusPoint>)this.Items).Add(stylusPoint);\n            }\n\n            if (stylusPoints.Count > 0)\n            {\n                OnChanged(EventArgs.Empty);\n            }\n        }","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointCollection.cs#L186-L222","documentation":"StylusPointCollection.Add(IEnumerable<StylusPoint>) throws ArgumentException when the incoming points' StylusPointDescription is not compatible with the collection's existing description. All points in one collection must share a compatible packet description (property set), enforced via StylusPointDescription.AreCompatible.","triggerScenarios":"Calling spc.Add(pointsFromAnotherCollectionOrDevice) whose Description has different/incompatible StylusPointProperties than the target collection (e.g. points from a different digitizer or created with a custom description).","commonSituations":"Merging strokes captured from two different tablet devices; copying points between collections built with different GetStylusDescriptions; mixing real device points with synthetically constructed points (default description).","solutions":["Reformat the points first: use sourceCollection.Reformat(targetDescription, transform) to convert them","Verify compatibility before adding with StylusPointDescription.AreCompatible(points.Description, target.Description)","Create the target collection from the same description as the points being added"],"exampleFix":"// before\ntargetStroke.StylusPoints.Add(sourceStroke.StylusPoints);\n// after\nvar reformatted = sourceStroke.StylusPoints.Reformat(targetStroke.StylusPoints.Description, null);\ntargetStroke.StylusPoints.Add(reformatted);","handlingStrategy":"validation","validationCode":"if (!StylusPointDescription.AreCompatible(source.Description, target.Description))\n    source = source.Reformat(target.Description, null);\ntarget.Add(source);","typeGuard":"bool CanAdd(StylusPointCollection target, StylusPointCollection src) => StylusPointDescription.AreCompatible(src.Description, target.Description);","tryCatchPattern":"try { target.Add(sourcePoints); } catch (ArgumentException ex) when (ex.ParamName == \"stylusPoints\") { target.Add(sourcePoints.Reformat(target.Description, null)); }","preventionTips":["Only merge strokes captured from the same device/packet description","Always Reformat between collections with different descriptions","Check AreCompatible before cross-collection copies"],"tags":["wpf","stylus","incompatible-description"],"backgroundTag":"incompatible-source-type","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}