{"record":{"id":"ed2867e920a6cc7c","repo":"dotnet/wpf","slug":"sr-manipulation-invalidmanipulationmode","errorCode":null,"errorMessage":"SR.Manipulation_InvalidManipulationMode","messagePattern":"SR\\.Manipulation_InvalidManipulationMode","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/ManipulationStartingEventArgs.cs","lineNumber":32,"sourceCode":"    {\n        internal ManipulationStartingEventArgs(\n            ManipulationDevice manipulationDevice, \n            int timestamp)\n            : base(manipulationDevice, timestamp)\n        {\n            RoutedEvent = Manipulation.ManipulationStartingEvent;\n            Mode = ManipulationModes.All;\n            IsSingleTouchEnabled = true;\n        }\n\n        public ManipulationModes Mode\n        {\n            get { return _mode; }\n            set\n            {\n                if ((value & ~ManipulationModes.All) != 0)\n                {\n                    throw new ArgumentException(SR.Manipulation_InvalidManipulationMode, nameof(value));\n                }\n\n                _mode = value;\n            }\n        }\n\n        /// <summary>\n        ///     The ManipulationContainer defines the coordinate space of all parameters\n        ///     and values for this manipulation.\n        /// </summary>\n        public IInputElement ManipulationContainer\n        {\n            get;\n            set;\n        }\n\n        /// <summary>\n        ///     For single-finger rotation, the pivot is used to determine how to rotate.","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/ManipulationStartingEventArgs.cs#L14-L50","documentation":"ManipulationStartingEventArgs.Mode setter throws ArgumentException with SR.Manipulation_InvalidManipulationMode when the assigned Manipulations value contains bits outside ManipulationModes.All. The Mode property only accepts valid ManipulationModes flag combinations. WPF validates the enum mask to prevent meaningless or future-invalid mode bits.","triggerScenarios":"Assigning e.Mode a value with undefined bits, e.g. (ManipulationModes)0x1000 cast from an int, or an arithmetic result like ManipulationModes.All << 1.","commonSituations":"Storing ManipulationModes in an int config and casting back without masking; combining modes with bitwise ops that accidentally set undefined high bits.","solutions":["Mask the value with ManipulationModes.All before assigning: e.Mode = value & ManipulationModes.All","Assign only named enum members or valid combinations of them","Validate parsed config values against ManipulationModes.All before use"],"exampleFix":"// before\ne.Mode = (ManipulationModes)rawConfigValue; // may contain invalid bits\n// after\nManipulationModes mode = rawConfigValue & ManipulationModes.All;\ne.Mode = mode;","handlingStrategy":"validation","validationCode":"if ((mode & ~ManipulationModes.All) != 0)\n    throw new ArgumentException(\"Invalid ManipulationModes value\", nameof(mode));\ne.Mode = mode;","typeGuard":"static bool IsValidManipulationMode(ManipulationModes m) => (m & ~ManipulationModes.All) == 0;","tryCatchPattern":"try { e.Mode = parsedMode; }\ncatch (ArgumentException) { e.Mode = ManipulationModes.All; }","preventionTips":["Mask config-derived ints with ManipulationModes.All before assigning","Never cast arbitrary ints to ManipulationModes without validation","Use only named enum members in flag combinations"],"tags":["wpf","touch","manipulation","argument","enum"],"backgroundTag":"invalid-enum-value","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"}