{"record":{"id":"4ded541f49d3642c","repo":"dotnet/wpf","slug":"sr-unsupported-mouseaction-mouseactiontoken","errorCode":null,"errorMessage":"SR.Unsupported_MouseAction (mouseActionToken)","messagePattern":"SR\\.Unsupported_MouseAction \\(mouseActionToken\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/MouseActionConverter.cs","lineNumber":70,"sourceCode":"        /// <returns>A <see cref=\"MouseAction\"/> representing the <see langword=\"string\"/> specified by <paramref name=\"source\"/>.</returns>\n        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object source)\n        {\n            if (source is not string mouseAction)\n                throw GetConvertFromException(source);\n\n            ReadOnlySpan<char> mouseActionToken = mouseAction.AsSpan().Trim();\n            return mouseActionToken switch\n            {\n                _ when mouseActionToken.IsEmpty => MouseAction.None, // Special casing as produced by \"ConvertTo\"\n                _ when mouseActionToken.Equals(\"None\", StringComparison.OrdinalIgnoreCase) => MouseAction.None,\n                _ when mouseActionToken.Equals(\"LeftClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.LeftClick,\n                _ when mouseActionToken.Equals(\"RightClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.RightClick,\n                _ when mouseActionToken.Equals(\"MiddleClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.MiddleClick,\n                _ when mouseActionToken.Equals(\"WheelClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.WheelClick,\n                _ when mouseActionToken.Equals(\"LeftDoubleClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.LeftDoubleClick,\n                _ when mouseActionToken.Equals(\"RightDoubleClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.RightDoubleClick,\n                _ when mouseActionToken.Equals(\"MiddleDoubleClick\", StringComparison.OrdinalIgnoreCase) => MouseAction.MiddleDoubleClick,\n                _ => throw new NotSupportedException(SR.Format(SR.Unsupported_MouseAction, mouseActionToken.ToString()))\n            };\n        }\n\n        /// <summary>\n        /// Converts a <paramref name=\"value\"/> of <see cref=\"MouseAction\"/> to its <see langword=\"string\"/> represensation.\n        /// </summary>\n        /// <param name=\"context\">Serialization Context</param>\n        /// <param name=\"culture\">Culture Info</param>\n        /// <param name=\"value\">MouseAction value </param>\n        /// <param name=\"destinationType\">Type to Convert</param>\n        /// <returns>A <see langword=\"string\"/> representing the <see cref=\"MouseAction\"/> specified by <paramref name=\"value\"/>.</returns>\n        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)\n        {\n            ArgumentNullException.ThrowIfNull(destinationType);\n\n            if (value is null || destinationType != typeof(string))\n                throw GetConvertToException(value, destinationType);\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/MouseActionConverter.cs#L52-L88","documentation":"MouseActionConverter.ConvertFrom parses a string into a MouseAction; a token that matches none of the known names (LeftClick, RightClick, MiddleClick, WheelClick, LeftDoubleClick, RightDoubleClick, MiddleDoubleClick) throws NotSupportedException with SR.Unsupported_MouseAction. Matching is case-insensitive but the text must equal one of these tokens exactly.","triggerScenarios":"Calling ConvertFrom with strings like \"Click\", \"LeftClick2\", \"DoubleClick\", or localized/translated names; also XAML attribute values with typos.","commonSituations":"XAML MouseBinding Gesture=\"Click\" (missing the Left prefix) or parsing user-supplied shortcut strings that don't match the canonical token names.","solutions":["Use one of the exact token names: LeftClick, RightClick, MiddleClick, WheelClick, LeftDoubleClick, RightDoubleClick, MiddleDoubleClick (case-insensitive)","Fix typos in XAML, e.g. Gesture=\"LeftClick\" instead of \"Click\"","Pre-validate the string against the token list and show a friendly message"],"exampleFix":"// before\n<MouseBinding Gesture=\"Click\" Command=\"...\"/>\n// after\n<MouseBinding Gesture=\"LeftClick\" Command=\"...\"/>","handlingStrategy":"validation","validationCode":"string[] valid = {\"LeftClick\",\"RightClick\",\"MiddleClick\",\"WheelClick\",\"LeftDoubleClick\",\"RightDoubleClick\",\"MiddleDoubleClick\"};\nbool ok = valid.Contains(s, StringComparer.OrdinalIgnoreCase);","typeGuard":null,"tryCatchPattern":"try { action = (MouseAction)converter.ConvertFrom(s); } catch (NotSupportedException ex) { /* unknown MouseAction token */ }","preventionTips":["Use exact canonical token names in XAML and config (case-insensitive)","Remember 'Click' alone is invalid — use 'LeftClick'","Validate user-entered action strings against the token list"],"tags":["wpf","input","mouseaction","converter","xaml"],"backgroundTag":"invalid-argument-format","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"}