{"record":{"id":"5bd5ca5db19d5a5f","repo":"dotnet/wpf","slug":"sr-format-sr-pagecontentunsupportedpagetype-o-gettype","errorCode":null,"errorMessage":"SR.Format(SR.PageContentUnsupportedPageType, o.GetType())","messagePattern":"SR\\.Format\\(SR\\.PageContentUnsupportedPageType, o\\.GetType\\(\\)\\)","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/PageContent.cs","lineNumber":618,"sourceCode":"            };\n\n            if (BindUriHelper.IsXamlMimeType(mimeType))\n            {\n                XpsValidatingLoader loader = new XpsValidatingLoader();\n                o = loader.Load(pageStream, baseUri, pc, mimeType);\n            }\n            else if (MS.Internal.MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(mimeType))\n            {\n                o = XamlReader.LoadBaml(pageStream, pc, null, true);\n            }\n            else\n            {\n                throw new ApplicationException(SR.PageContentUnsupportedMimeType);\n            }\n\n            if (o != null && !(o is FixedPage))\n            {\n                throw new ApplicationException(SR.Format(SR.PageContentUnsupportedPageType, o.GetType()));\n            }\n\n            fixedPage =  (FixedPage)o;\n        }\n\n        #endregion Private Methods\n\n        //--------------------------------------------------------------------\n        //\n        // Private Fields\n        //\n        //---------------------------------------------------------------------\n\n        #region Private Fields\n        private WeakReference _pageRef;         // weak ref to page's root visual\n        private FixedPage     _child;              // directly hosted page stream\n        private PageContentAsyncResult  _asyncOp;\n        private HybridDictionary  _pendingStreams;","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/PageContent.cs#L600-L636","documentation":"_LoadPageImpl throws ApplicationException with SR.PageContentUnsupportedPageType when the XAML/BAML parse succeeds but the root object is not a FixedPage. A PageContent can only present FixedPage content, so any other root element type is rejected.","triggerScenarios":"GetPage on a PageContent whose Source XAML has a root element other than FixedPage (e.g. a raw Canvas, UserControl, or FlowDocument).","commonSituations":"Authoring page XAML with the wrong root element; reusing application XAML files as XPS page parts; migration/refactor that changed the page's root type.","solutions":["Make the loaded XAML root element a <FixedPage>","Move non-FixedPage content inside a FixedPage root","Re-author or convert the page part to the XPS FixedPage schema"],"exampleFix":"// before\n<Canvas xmlns=...> ... </Canvas>\n// after\n<FixedPage xmlns=... xmlns:x=... Width=\"816\" Height=\"1056\"> ... </FixedPage>","handlingStrategy":"validation","validationCode":"// after load, before GetPage:\n// parse root element name and require \"FixedPage\"","typeGuard":"bool IsFixedPage(object o) => o is FixedPage;","tryCatchPattern":"try { var p = pageContent.GetPage(); } catch (ApplicationException) { /* root element not FixedPage: fix XAML */ }","preventionTips":["Always use <FixedPage> as the root element of page parts","Lint XPS page XAML against the FixedPage schema","Do not reuse non-page XAML files as XPS page content"],"tags":["wpf","xps","type-mismatch","xaml"],"backgroundTag":"type-mismatch","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"}