{"record":{"id":"46db84ddbca2cd41","repo":"dotnet/wpf","slug":"sr-stylus-canonlycallfordownmoveorup","errorCode":null,"errorMessage":"SR.Stylus_CanOnlyCallForDownMoveOrUp","messagePattern":"SR\\.Stylus_CanOnlyCallForDownMoveOrUp","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs","lineNumber":121,"sourceCode":"                throw new ArgumentException(SR.IncompatibleStylusPointDescriptions, nameof(stylusPoints));\n            }\n            if (stylusPoints.Count == 0)\n            {\n                throw new ArgumentException(SR.Stylus_StylusPointsCantBeEmpty, nameof(stylusPoints));\n            }\n\n            _stylusPoints = stylusPoints.Clone();\n        }\n\n        /// <summary>\n        /// Returns the RawStylusInputCustomDataList used to notify plugins before  \n        /// PreviewStylus event has been processed by application.\n        /// </summary>\n        public void NotifyWhenProcessed(object callbackData)\n        {\n            if (_currentNotifyPlugIn == null)\n            {\n                throw new InvalidOperationException(SR.Stylus_CanOnlyCallForDownMoveOrUp);\n            }\n            if (_customData == null)\n            {\n                _customData = new RawStylusInputCustomDataList();\n            }\n            _customData.Add(new RawStylusInputCustomData(_currentNotifyPlugIn, callbackData));\n        }\n\n        /// <summary>\n        /// True if a StylusPlugIn has modifiedthe StylusPoints.\n        /// </summary>\n        internal bool StylusPointsModified\n        {\n            get \n            {\n                return _stylusPoints != null;\n            }\n        }","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs#L103-L139","documentation":"NotifyWhenProcessed lets a StylusPlugIn request a callback after the PreviewStylus* event has traversed the application. It only works while the plug-in is servicing a Down/Move/Up raw input, when the ambient _currentNotifyPlugIn is set; otherwise WPF throws this InvalidOperationException.","triggerScenarios":"Calling NotifyWhenProcessed outside the dynamic call stack of OnStylusDown/OnStylusMove/OnStylusUp — e.g. storing the RawStylusInput and calling later, or calling from OnStylusEnter/OnStylusLeave/OnStylusInRange/OnStylusOutOfRange or from arbitrary app code.","commonSituations":"Deferring the call to a dispatcher work item or a timer instead of calling it synchronously inside the stylus event handler; assuming it works for hover events like InRange/OutOfRange where no notification is supported.","solutions":["Call NotifyWhenProcessed synchronously inside OnStylusDown, OnStylusMove, or OnStylusUp only","If a deferred callback is needed, capture the data in the handler and use NotifyWhenProcessed there, scheduling your own work from the resulting callback","Remove calls from non-Down/Move/Up handlers (Enter/Leave/InRange/OutOfRange) and use other mechanisms (e.g. element events) there"],"exampleFix":"// before\nprotected override void OnStylusInRange(RawStylusInput rawStylusInput)\n{\n    rawStylusInput.NotifyWhenProcessed(this); // throws\n}\n// after\nprotected override void OnStylusMove(RawStylusInput rawStylusInput)\n{\n    rawStylusInput.NotifyWhenProcessed(this); // valid: Down/Move/Up only\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { rawStylusInput.NotifyWhenProcessed(data); } catch (InvalidOperationException) { /* not in Down/Move/Up dispatch; handle inline instead */ }","preventionTips":["Call NotifyWhenProcessed only synchronously inside OnStylusDown/OnStylusMove/OnStylusUp","Never stash RawStylusInput for later calls","Use plug-in Enter/Leave/InRange/OutOfRange handlers without NotifyWhenProcessed"],"tags":["wpf","stylus","invalid-operation"],"backgroundTag":"invalid-state-transition","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"}