{"record":{"id":"402223131685d00b","repo":"dotnet/wpf","slug":"sr-manipulation-manipulationnotactive","errorCode":null,"errorMessage":"SR.Manipulation_ManipulationNotActive","messagePattern":"SR\\.Manipulation_ManipulationNotActive","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Manipulation.cs","lineNumber":73,"sourceCode":"        /// <param name=\"element\">The element on which there is an active manipulation.</param>\n        public static void StartInertia(UIElement element)\n        {\n            ArgumentNullException.ThrowIfNull(element);\n\n            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);\n            device?.CompleteManipulation(withInertia: true);\n        }\n\n        /// <summary>\n        ///     If a manipulation is active, forces the manipulation to complete.\n        /// </summary>\n        /// <param name=\"element\">The element on which there is an active manipulation.</param>\n        public static void CompleteManipulation(UIElement element)\n        {\n            ArgumentNullException.ThrowIfNull(element);\n            if (!TryCompleteManipulation(element))\n            {\n                throw new InvalidOperationException(SR.Manipulation_ManipulationNotActive);\n            }\n        }\n\n        internal static bool TryCompleteManipulation(UIElement element)\n        {\n            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);\n            if (device != null)\n            {\n                device.CompleteManipulation(withInertia: false);\n                return true;\n            }\n\n            return false;\n        }\n\n        /// <summary>\n        ///     Changes the manipulation mode of an active manipulation.\n        /// </summary>","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Manipulation.cs#L55-L91","documentation":"Manipulation.CompleteManipulation requires an active manipulation on the element. If TryCompleteManipulation fails (no ManipulationDevice is tracking the element), it throws InvalidOperationException with Manipulation_ManipulationNotActive.","triggerScenarios":"Calling Manipulation.CompleteManipulation(element) when no touch manipulation is currently active on that element (manipulation already completed, never started, or released).","commonSituations":"Programmatically ending a touch gesture after the user already lifted their finger; calling completion from async code where the manipulation ended first; double-completing in response to ManipulationCompleted.","solutions":["Use the internal-style check first: track whether manipulation is active before calling, or wrap in try-catch for InvalidOperationException","Call CompleteManipulation only in response to live touch input (e.g. before ManipulationCompleted fires)","Track manipulation state via ManipulationStarted/ManipulationCompleted events"],"exampleFix":"// before\nManipulation.CompleteManipulation(element);\n// after\nif (isManipulating) // tracked via ManipulationStarted/Completed events\n    Manipulation.CompleteManipulation(element);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Manipulation.CompleteManipulation(element); } catch (InvalidOperationException) { /* no active manipulation; safe to ignore */ }","preventionTips":["Track ManipulationStarted/Completed to know when completion is legal","Never call CompleteManipulation outside a live manipulation window"],"tags":["wpf","touch","manipulation"],"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"}