{"record":{"id":"db11aeec96b232d2","repo":"dotnet/wpf","slug":"sr-manipulation-manipulationnotenabled","errorCode":null,"errorMessage":"SR.Manipulation_ManipulationNotEnabled","messagePattern":"SR\\.Manipulation_ManipulationNotEnabled","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Manipulation.cs","lineNumber":219,"sourceCode":"                return device.ManipulationPivot;\n            }\n\n            return null;\n        }\n\n        /// <summary>\n        ///     Associates a manipulator with a UIElement. This will either will start an \n        ///     active manipulation or add to an existing one.\n        /// </summary>\n        /// <param name=\"element\">The element with which to associate the manipulator.</param>\n        /// <param name=\"manipulator\">The manipulator, such as a TouchDevice.</param>\n        public static void AddManipulator(UIElement element, IManipulator manipulator)\n        {\n            ArgumentNullException.ThrowIfNull(element);\n            ArgumentNullException.ThrowIfNull(manipulator);\n            if (!element.IsManipulationEnabled)\n            {\n                throw new InvalidOperationException(SR.Manipulation_ManipulationNotEnabled);\n            }\n\n            ManipulationDevice device = ManipulationDevice.AddManipulationDevice(element);\n            device.AddManipulator(manipulator);\n        }\n\n        /// <summary>\n        ///     Disassociates a manipulator with a UIElement. This will remove it from\n        ///     an active manipulation, possibly completing it.\n        /// </summary>\n        /// <param name=\"element\">The element that the manipulator used to be associated with.</param>\n        /// <param name=\"manipulator\">The manipulator, such as a TouchDevice.</param>\n        public static void RemoveManipulator(UIElement element, IManipulator manipulator)\n        {\n            ArgumentNullException.ThrowIfNull(element);\n            ArgumentNullException.ThrowIfNull(manipulator);\n\n            if (!TryRemoveManipulator(element, manipulator))","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Manipulation.cs#L201-L237","documentation":"Manipulation.AddManipulator throws InvalidOperationException with SR.Manipulation_ManipulationNotEnabled when element.IsManipulationEnabled is false. A custom IManipulator can only be attached to an element that has manipulation enabled via ManipulationMode. WPF requires the element be opted into manipulation processing before manipulators may be added.","triggerScenarios":"Calling Manipulation.AddManipulator(element, manipulator) on an element whose ManipulationMode is None (or unset), so IsManipulationEnabled is false.","commonSituations":"Registering a custom manipulator on an element that was never configured for touch manipulation, or on one whose ManipulationMode was reset to None at runtime.","solutions":["Set element.IsManipulationEnabled = true (or ManipulationMode to a value other than None) before calling AddManipulator","Verify no code path resets ManipulationMode to None prior to the call","Guard the call with an IsManipulationEnabled check"],"exampleFix":"// before\nManipulation.AddManipulator(element, myManipulator); // throws: not enabled\n// after\nif (!element.IsManipulationEnabled)\n{\n    element.IsManipulationEnabled = true;\n}\nManipulation.AddManipulator(element, myManipulator);","handlingStrategy":"validation","validationCode":"if (element == null || manipulator == null) throw new ArgumentNullException(nameof(element));\nif (!element.IsManipulationEnabled) element.IsManipulationEnabled = true;","typeGuard":"static bool CanAddManipulator(UIElement e) => e != null && e.IsManipulationEnabled;","tryCatchPattern":"try { Manipulation.AddManipulator(element, manipulator); }\ncatch (InvalidOperationException) { element.IsManipulationEnabled = true; Manipulation.AddManipulator(element, manipulator); }","preventionTips":["Set ManipulationMode (not None) in XAML or constructor for elements receiving custom manipulators","Audit code that resets ManipulationMode at runtime","Check IsManipulationEnabled before AddManipulator"],"tags":["wpf","touch","manipulation","invalid-operation"],"backgroundTag":"feature-not-enabled","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"}