dotnet/wpf · error
SR.DocumentGridInvalidViewMode
Error message
SR.DocumentGridInvalidViewMode
What it means
ArgumentException sentinel from DocumentGrid: an unrecognized ViewMode value reached internal layout logic (the enum switch's default case), i.e. the view mode is outside the supported set, so layout cannot compute a scale factor.
Solutions
- Set ViewMode using DocumentViewMode enum values rather than raw casts
- Validate externally supplied mode values against the known enum before assigning
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/DocumentGrid.cs:2456 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/0705f1ce68f194d6.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/DocumentGrid.cs:2456
//If we have no space to display pages, there's nothing to scale.
//So just return 1.0 to indicate no change.
if (thumbnailCompensatedViewportHeight <= 0.0)
{
scaleFactor = 1.0;
}
else
{
scaleFactor = Math.Min(compensatedViewportWidth / rowWidth,
thumbnailCompensatedViewportHeight / thumbnailCompensatedExtentHeight);
}
break;
case ViewMode.Zoom:
//We will not change the scale here, as this is not a "page-fit" mode.
break;
default:
throw new InvalidOperationException(SR.DocumentGridInvalidViewMode);
}
return scaleFactor;
}
/// <summary>
/// Creates the caches used by DocumentGrid, and sets default property values.
/// </summary>
private void Initialize()
{
//Create our caches
_pageCache = new PageCache();
_childrenCollection = new VisualCollection(this);
_rowCache = new RowCache
{
PageCache = _pageCache
};View on GitHub (pinned to 81131a70a4)