dotnet/wpf · error · ArgumentException
SR.InvalidStylusPointDescription
Error message
SR.InvalidStylusPointDescription
What it means
The StylusPointDescription constructor validates that its StylusPointPropertyInfoCollection contains at least the required properties (X, Y, NormalPressure) in the required order. This ArgumentException is thrown when the collection is missing one of these mandatory properties or has them in the wrong order, because a StylusPoint without X, Y and pressure data cannot be represented in WPF's stylus pipeline.
Solutions
- Ensure the StylusPointPropertyInfo collection starts with exactly StylusPointPropertyInfoForX, StylusPointPropertyInfoForY, then StylusPointPropertyInfoForNormalPressure, in that order.
- Append any additional properties (custom axes) after those first three.
- Append StylusPointPropertyInfo button entries last (buttons must come after all non-button properties).
- If constructing from raw device data, map each packet field to a StylusPointPropertyInfo and skip fields that do not map to X/Y/pressure, placing them after the required trio.
Example fix
// before
var infos = new StylusPointPropertyInfo[] {
new StylusPointPropertyInfo(StylusPointPropertyIds.NormalPressure),
new StylusPointPropertyInfo(StylusPointPropertyIds.X),
new StylusPointPropertyInfo(StylusPointPropertyIds.Y)};
var desc = new StylusPointDescription(infos);
// after
var infos = new StylusPointPropertyInfo[] {
StylusPointPropertyInfo.StylusPointPropertyInfoForX,
StylusPointPropertyInfo.StylusPointPropertyInfoForY,
StylusPointPropertyInfo.StylusPointPropertyInfoForNormalPressure};
var desc = new StylusPointDescription(infos); Defensive patterns
Strategy: validation
Validate before calling
bool ok = infos != null && infos.Count >= 3 &&
infos[0].Id == StylusPointPropertyIds.X &&
infos[1].Id == StylusPointPropertyIds.Y &&
infos[2].Id == StylusPointPropertyIds.NormalPressure;
if (!ok) throw new ArgumentException("First three properties must be X, Y, NormalPressure", nameof(infos)); Try / catch
try { var desc = new StylusPointDescription(infos); }
catch (ArgumentException) { /* fall back to stylusDevice.StylusPointDescription or default description */ } Prevention
- Always start the collection with the X, Y, NormalPressure predefined StylusPointPropertyInfos
- Append custom axes after the required trio
- Keep buttons last and in device order
When it happens
Trigger: Calling new StylusPointDescription(stylusPointPropertyInfos) where the collection has fewer than 3 entries, or infos[0].Id != StylusPointPropertyIds.X, or infos[1].Id != StylusPointPropertyIds.Y, or infos[2].Id != StylusPointPropertyIds.NormalPressure.
Common situations: Building a custom StylusPointDescription for a digitizer/tablet integration and forgetting that X, Y, and NormalPressure must be the first three properties in exactly that order; copying property lists from raw device packets where pressure was omitted; reordering the collection to put buttons or custom properties first.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- SR.Format(SR.Invalid_IInputElement, _stylusOver.GetType())
- SR.IncompatibleStylusPointDescriptions
- SR.InvalidIsButtonForId
- SR.InvalidIsButtonForId2
- SR.InvalidStylusPointDescriptionButtonsMustBeLast
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/e71f00f77f10f7f4.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointDescription.cs:55
StylusPointPropertyInfoDefaults.NormalPressure
};
}
/// <summary>
/// StylusPointDescription
/// </summary>
public StylusPointDescription(IEnumerable<StylusPointPropertyInfo> stylusPointPropertyInfos)
{
ArgumentNullException.ThrowIfNull(stylusPointPropertyInfos);
List<StylusPointPropertyInfo> infos =
new List<StylusPointPropertyInfo>(stylusPointPropertyInfos);
if (infos.Count < RequiredCountOfProperties ||
infos[RequiredXIndex].Id != StylusPointPropertyIds.X ||
infos[RequiredYIndex].Id != StylusPointPropertyIds.Y ||
infos[RequiredPressureIndex].Id != StylusPointPropertyIds.NormalPressure)
{
throw new ArgumentException(SR.InvalidStylusPointDescription, nameof(stylusPointPropertyInfos));
}
//
// look for duplicates, validate that buttons are last
//
List<Guid> seenIds = new List<Guid>();
seenIds.Add(StylusPointPropertyIds.X);
seenIds.Add(StylusPointPropertyIds.Y);
seenIds.Add(StylusPointPropertyIds.NormalPressure);
int buttonCount = 0;
for (int x = RequiredCountOfProperties; x < infos.Count; x++)
{
if (seenIds.Contains(infos[x].Id))
{
throw new ArgumentException(SR.InvalidStylusPointDescriptionDuplicatesFound, nameof(stylusPointPropertyInfos));
}
if (infos[x].IsButton)View on GitHub (pinned to 81131a70a4)