{"record":{"id":"194738f592a172ce","repo":"dotnet/wpf","slug":"sr-cliptoboundsnotsupported","errorCode":null,"errorMessage":"SR.ClipToBoundsNotSupported","messagePattern":"SR\\.ClipToBoundsNotSupported","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs","lineNumber":6321,"sourceCode":"                // setting this value is allowed.\n            }\n            else\n            {\n                throw new InvalidOperationException(SR.TransformNotSupported);\n            }\n\n            return value;\n        }\n\n        private static void _OnRenderTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\n        {\n        }\n\n        private static object CoerceClipToBounds(DependencyObject d, object value)\n        {\n            if ((bool)value)\n            {\n                throw new InvalidOperationException(SR.ClipToBoundsNotSupported);\n            }\n            return value;\n        }\n\n        private static void _OnClipToBoundsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\n        {\n        }\n\n\n        /// <summary>\n        ///     Get or create the hidden window used for parenting when ShowInTaskbar == false.\n        /// </summary>\n        private HwndWrapper EnsureHiddenWindow()\n        {\n            if (_hiddenWindow == null)\n            {\n                _hiddenWindow = new HwndWrapper(\n                    0, // classStyle","sourceCodeStart":6303,"sourceCodeEnd":6339,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs#L6303-L6339","documentation":"Window.CoerceClipToBounds rejects any attempt to set Window.ClipToBounds to true, because clipping a top-level window to its layout bounds is meaningless for an HWND-based window. Setting true throws InvalidOperationException; false (the default) is accepted. This is a documented WPF restriction on Window.","triggerScenarios":"Setting Window.ClipToBounds=\"True\" in XAML, assigning window.ClipToBounds = true in code, or a style/binding/animation that coerces the property to true.","commonSituations":"Copy-pasting a UserControl's properties onto a Window, applying a shared style with ClipToBounds=true to all FrameworkElements including the Window, trying to clip overflow animations at the window edge.","solutions":["Remove ClipToBounds=true from the Window (it is unnecessary — an HWND window is inherently clipped to its bounds)","Apply ClipToBounds on an inner element such as a Grid or Border if clipping of content is intended","Refactor shared styles so the ClipToBounds setter targets inner elements only (e.g. use x:Key or a more specific selector)"],"exampleFix":"// before\n<Window ClipToBounds=\"True\">...</Window>\n// after\n<Window><Grid ClipToBounds=\"True\">...</Grid></Window>","handlingStrategy":"validation","validationCode":"if (isWindow && ClipToBounds) throw new ArgumentException(\"Window.ClipToBounds must be false\");","typeGuard":null,"tryCatchPattern":"try { window.ClipToBounds = true; } catch (InvalidOperationException) { contentRoot.ClipToBounds = true; }","preventionTips":["Exclude Window from shared FrameworkElement styles that set ClipToBounds","Remember top-level HWNDs are inherently clipped; only inner elements need ClipToBounds","Audit styles applied to Window for control-oriented properties"],"tags":["wpf","window","cliptobounds","not-supported"],"backgroundTag":"unsupported-operation","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"}