{"record":{"id":"d4783a0f93aab95b","repo":"dotnet/wpf","slug":"sr-invalidisbuttonforid2","errorCode":null,"errorMessage":"SR.InvalidIsButtonForId2","messagePattern":"SR\\.InvalidIsButtonForId2","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointProperty.cs","lineNumber":63,"sourceCode":"        private void Initialize(Guid identifier, bool isButton)\n        {\n            //\n            // validate isButton for known guids\n            //\n            if (StylusPointPropertyIds.IsKnownButton(identifier))\n            {\n                if (!isButton)\n                {\n                    //error, this is a known button\n                    throw new ArgumentException(SR.InvalidIsButtonForId, nameof(isButton));\n                }\n            }\n            else\n            {\n                if (StylusPointPropertyIds.IsKnownId(identifier) && isButton)\n                {\n                    //error, this is a known guid that is NOT a button\n                    throw new ArgumentException(SR.InvalidIsButtonForId2, nameof(isButton));\n                }\n            }\n\n            _id = identifier;\n            _isButton = isButton;\n        }\n\n        /// <summary>\n        /// Id\n        /// </summary>\n        public Guid Id \n        {\n            get { return _id; }\n        }\n\n        /// <summary>\n        /// IsButton\n        /// </summary>","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointProperty.cs#L45-L81","documentation":"The complementary check in StylusPointProperty.Initialize: if the identifier is a known non-button Guid (a standard axis like X, Y, NormalPressure) but isButton is true, an ArgumentException naming isButton is thrown. Known Guids have fixed semantics, so marking a standard axis property as a button is invalid.","triggerScenarios":"Calling new StylusPointProperty(StylusPointPropertyIds.X /* or any known non-button Guid */, true).","commonSituations":"Wrapping raw device Guids with isButton true whenever the packet field looks boolean; bulk-constructing properties from a device capability list with an incorrect button flag column; trying to create a custom button with an accidental known-Guid value.","solutions":["Pass false for known non-button Guids; only button Guids (TipButton/BarrelButton) accept true.","For custom buttons use a newly generated Guid (Guid.NewGuid) with isButton true rather than a known Guid.","Derive the flag: new StylusPointProperty(id, StylusPointPropertyIds.IsKnownButton(id))."],"exampleFix":"// before\nvar prop = new StylusPointProperty(StylusPointPropertyIds.X, true);\n// after\nvar prop = new StylusPointProperty(StylusPointPropertyIds.X, false);","handlingStrategy":"validation","validationCode":"bool valid = !isButton || StylusPointPropertyIds.IsKnownButton(id);","typeGuard":null,"tryCatchPattern":"try { var p = new StylusPointProperty(id, isButton); }\ncatch (ArgumentException) { p = new StylusPointProperty(id, false); }","preventionTips":["Pass isButton true only for known button Guids or fresh custom Guids","Never mark standard axis Guids (X, Y, NormalPressure) as buttons","Validate capability lists before mapping to properties"],"tags":["wpf","stylus","argument-exception","enum"],"backgroundTag":"invalid-argument-value","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"}