{"record":{"id":"f846fb58addb13c1","repo":"PrismLibrary/Prism","slug":"resources-deactivenotpossibleexception","errorCode":null,"errorMessage":"Resources.DeactiveNotPossibleException","messagePattern":"Resources\\.DeactiveNotPossibleException","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs","lineNumber":23,"sourceCode":"    /// <summary>\n    /// Region that keeps all the views in it as active. Deactivation of views is not allowed.\n    /// </summary>\n    public class AllActiveRegion : Region\n    {\n        /// <summary>\n        /// Gets a readonly view of the collection of all the active views in the region. These are all the added views.\n        /// </summary>\n        /// <value>An <see cref=\"IViewsCollection\"/> of all the active views.</value>\n        public override IViewsCollection ActiveViews => Views;\n\n        /// <summary>\n        /// Deactivate is not valid in this Region. This method will always throw <see cref=\"InvalidOperationException\"/>.\n        /// </summary>\n        /// <param name=\"view\">The view to deactivate.</param>\n        /// <exception cref=\"InvalidOperationException\">Every time this method is called.</exception>\n        public override void Deactivate(object view)\n        {\n            throw new InvalidOperationException(Resources.DeactiveNotPossibleException);\n        }\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":27,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs#L5-L27","documentation":"AllActiveRegion keeps every added view active, so it has no notion of deactivation; its Deactivate override unconditionally throws InvalidOperationException with Resources.DeactiveNotPossibleException. This is a deliberate API contract: if you need per-view activation states, use a SingleActiveRegion instead.","triggerScenarios":"Calling region.Deactivate(view) on a region instance that is an AllActiveRegion — typically via IRegionManager region lookup, IRegion.ActiveViews manipulation, or view lifecycle code that assumes deactivation is supported.","commonSituations":"Tab-like UIs where developers expect to hide views but the region was registered with AllActiveRegion; code shared between regions of different kinds calling Deactivate polymorphically; migrating code from SingleActiveRegion to AllActiveRegion.","solutions":["Use a SingleActiveRegion (e.g., RegisterViewWithRegion with a region whose adapter supports activation) if you need Deactivate semantics.","Remove the Deactivate call and rely on Region.Remove(view) if the view should disappear entirely.","Guard polymorphic code: only call Deactivate when the region actually supports it.","Keep the view in the region and manage visibility through your own mechanism if AllActiveRegion behavior is required."],"exampleFix":"// before\nregion.Deactivate(myView); // region is AllActiveRegion -> throws\n// after\nif (region is AllActiveRegion)\n    region.Remove(myView);\nelse\n    region.Deactivate(myView);","handlingStrategy":"type-guard","validationCode":"if (region is AllActiveRegion)\n    throw new InvalidOperationException(\"This region keeps all views active; Deactivate is not supported.\");","typeGuard":"bool SupportsDeactivate(IRegion region) => region is not AllActiveRegion;","tryCatchPattern":"try\n{\n    region.Deactivate(view);\n}\ncatch (InvalidOperationException ex) when (region is AllActiveRegion)\n{\n    logger.LogWarning(\"Deactivate unsupported on AllActiveRegion; removing view instead.\");\n    region.Remove(view);\n}","preventionTips":["Know which region type each region name maps to","Use SingleActiveRegion when per-view activation is needed","Guard polymorphic Deactivate calls on IRegion"],"tags":["wpf","regions","navigation","invalid-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}