{"record":{"id":"38b0fe7ec1718d64","repo":"dotnet/wpf","slug":"sr-pagecachesizenotallowed","errorCode":null,"errorMessage":"SR.PageCacheSizeNotAllowed","messagePattern":"SR\\.PageCacheSizeNotAllowed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/GroupItem.cs","lineNumber":264,"sourceCode":"            }\n            else\n            {\n                Generator.Release();\n            }\n\n            ClearContentControl(item);\n        }\n\n        #region IHierarchicalVirtualizationAndScrollInfo\n\n        HierarchicalVirtualizationConstraints IHierarchicalVirtualizationAndScrollInfo.Constraints\n        {\n            get { return HierarchicalVirtualizationConstraintsField.GetValue(this); }\n            set\n            {\n                if (value.CacheLengthUnit == VirtualizationCacheLengthUnit.Page)\n                {\n                    throw new InvalidOperationException(SR.PageCacheSizeNotAllowed);\n                }\n                HierarchicalVirtualizationConstraintsField.SetValue(this, value);\n            }\n        }\n\n        HierarchicalVirtualizationHeaderDesiredSizes IHierarchicalVirtualizationAndScrollInfo.HeaderDesiredSizes\n        {\n            get\n            {\n                FrameworkElement headerElement = HeaderElement;\n                Size pixelHeaderSize = new Size();\n\n                if (this.IsVisible && headerElement != null)\n                {\n                    pixelHeaderSize = headerElement.DesiredSize;\n                    Helper.ApplyCorrectionFactorToPixelHeaderSize(ParentItemsControl, this, _itemsHost, ref pixelHeaderSize);\n                }\n","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/GroupItem.cs#L246-L282","documentation":"The IHierarchicalVirtualizationAndScrollInfo.Constraints implementation on GroupItem rejects a HierarchicalVirtualizationConstraints whose CacheLengthUnit is VirtualizationCacheLengthUnit.Page. Page-based cache length is not supported for this path, so an InvalidOperationException is thrown when the value is set.","triggerScenarios":"Setting HierarchicalVirtualizationConstraints (via the interface setter, typically from VirtualizingPanel/virtualization infrastructure or custom panel code) with CacheLengthUnit set to Page instead of Item or Pixel.","commonSituations":"Configuring VirtualizingPanel.CacheLengthUnit=\"Page\" on an ItemsControl whose virtualization flows through hierarchical (tree/grid) virtualization constraints; custom virtualizing panels forwarding Page units.","solutions":["Use VirtualizationCacheLengthUnit.Item or Pixel instead of Page for cache length in hierarchical virtualization","Change CacheLengthUnit in XAML/resources to a supported unit","If page-like behavior is needed, approximate with a large Item-based CacheLength"],"exampleFix":"<!-- before -->\n<VirtualizingPanel CacheLengthUnit=\"Page\" CacheLength=\"1\"/>\n<!-- after -->\n<VirtualizingPanel CacheLengthUnit=\"Item\" CacheLength=\"10,10\"/>","handlingStrategy":"validation","validationCode":"if (constraints.CacheLengthUnit == VirtualizationCacheLengthUnit.Page) throw new InvalidOperationException(\"Page cache unit not supported here\");","typeGuard":"bool IsSupportedUnit(VirtualizationCacheLengthUnit u) => u != VirtualizationCacheLengthUnit.Page;","tryCatchPattern":"try { item.Constraints = constraints; } catch (InvalidOperationException) { constraints.CacheLengthUnit = VirtualizationCacheLengthUnit.Item; /* retry */ }","preventionTips":["Use Item or Pixel cache length units in hierarchical virtualization scenarios","Audit XAML for CacheLengthUnit=\"Page\" on tree/hierarchical controls","Convert page-based caching needs to equivalent item counts"],"tags":["wpf","virtualization","groupitem","cache"],"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"}