dotnet/wpf · error · ArgumentException
If AllGestures is specified, it must be the only…
Error message
If AllGestures is specified, it must be the only ApplicationGesture in the ApplicationGesture array.
What it means
Because ApplicationGesture.AllGestures is a wildcard, it cannot be combined with specific gestures. GetApplicationGestureArrayAndVerify throws ArgumentException (SR.AllGesturesMustExistAlone) if AllGestures appears together with any other gesture in the array passed to EnabledGestures.
Solutions
- Use AllGestures alone to enable all gestures
- Drop AllGestures from combined lists and rely on the specific gestures only
- Normalize: if AllGestures is present, assign new[]{ ApplicationGesture.AllGestures } and ignore the rest
Example fix
// before
recognizer.EnabledGestures = new[] { ApplicationGesture.AllGestures, ApplicationGesture.Down };
// after
recognizer.EnabledGestures = new[] { ApplicationGesture.AllGestures }; // or omit AllGestures and list specific gestures Defensive patterns
Strategy: validation
Validate before calling
bool hasAll = gestures.Contains(ApplicationGesture.AllGestures);
if (hasAll && gestures.Length > 1)
throw new ArgumentException("AllGestures must be the only entry", nameof(gestures)); Type guard
static bool AllGesturesAlone(ApplicationGesture[] g) => !g.Contains(ApplicationGesture.AllGestures) || g.Length == 1;
Try / catch
try { recognizer.EnabledGestures = gestures; }
catch (ArgumentException) { recognizer.EnabledGestures = new[]{ ApplicationGesture.AllGestures }; } Prevention
- If AllGestures is present, assign it alone and skip the rest
- Document AllGestures as a wildcard that excludes specific entries
- Normalize merged gesture configs before applying
When it happens
Trigger: Assigning EnabledGestures = new[]{ ApplicationGesture.AllGestures, ApplicationGesture.Down, ... } or appending AllGestures to a specific list.
Common situations: 'Enable everything plus these extras' configurations; merging an AllGestures default with per-app gesture selections.
Related errors
- Duplicate ApplicationGesture values are not allowed.
- InkSerializedFormat operation failed.
- Invalid argument passed to ReliableRead
- Maximum number of strokes is two.
- SR.InvalidGuid
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/da9a0f1b24bc6d14.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs:240
if (gesture == ApplicationGesture.AllGestures)
{
foundAllGestures = true;
}
//check for dupes
if (gestures.Contains(gesture))
{
throw new ArgumentException(SR.DuplicateApplicationGestureFound, nameof(applicationGestures));
}
gestures.Add(gesture);
}
// AllGesture cannot be specified with other gestures
if (foundAllGestures && gestures.Count != 1)
{
// no dupes allowed
throw new ArgumentException(SR.AllGesturesMustExistAlone, nameof(applicationGestures));
}
return gestures.ToArray();
}
#endregion Internal Methods
//-------------------------------------------------------------------------------
//
// IDisposable
//
//-------------------------------------------------------------------------------
#region IDisposable
/// <summary>
/// A simple pattern of the dispose implementation.
/// There is no finalizer since the SafeHandle will take care of releasing the context.View on GitHub (pinned to 81131a70a4)