{"record":{"id":"337e15843e729554","repo":"dotnet/wpf","slug":"sr-mustusewindowstylenone","errorCode":null,"errorMessage":"SR.MustUseWindowStyleNone","messagePattern":"SR\\.MustUseWindowStyleNone","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs","lineNumber":6932,"sourceCode":"            if ((_hiddenWindow != null) && (_hiddenWindow.Handle == _ownerHandle))\n            {\n                SetOwnerHandle(IntPtr.Zero);\n            }\n        }\n\n        private void VerifyConsistencyWithAllowsTransparency()\n        {\n            if (AllowsTransparency)\n            {\n                VerifyConsistencyWithAllowsTransparency(WindowStyle);\n            }\n        }\n\n        private void VerifyConsistencyWithAllowsTransparency(WindowStyle style)\n        {\n            if (AllowsTransparency && style != WindowStyle.None)\n            {\n                throw new InvalidOperationException(SR.MustUseWindowStyleNone);\n            }\n        }\n\n        private void VerifyConsistencyWithShowActivated()\n        {\n            //\n            // We don't support to show a maximized non-activated window.\n            // Don't check this consistency in a RBW (would break because Visibility is set when launching the RBW).\n            //\n            if (!_inTrustedSubWindow && WindowState == WindowState.Maximized && !ShowActivated)\n                throw new InvalidOperationException(SR.ShowNonActivatedAndMaximized);\n        }\n\n        private static bool IsValidSizeToContent(SizeToContent value)\n        {\n            return value == SizeToContent.Manual ||\n                   value == SizeToContent.Width ||\n                   value == SizeToContent.Height ||","sourceCodeStart":6914,"sourceCodeEnd":6950,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs#L6914-L6950","documentation":"Window.AllowsTransparency=true requires the window to be rendered by WPF itself with no non-client frame, so only WindowStyle.None is compatible. VerifyConsistencyWithAllowsTransparency throws InvalidOperationException when AllowsTransparency is true and the WindowStyle is SingleBorderWindow, ThreeDBorderWindow, or ToolWindow. The check runs when either property changes.","triggerScenarios":"Setting WindowStyle=\"SingleBorderWindow\" (or ToolWindow/ThreeDBorderWindow) together with AllowsTransparency=\"True\" in XAML or code — in either order, since the consistency is verified on each change.","commonSituations":"Enabling transparency for a custom-chrome window but forgetting to also set WindowStyle=\"None\", designer-generated XAML with conflicting attributes, migrating apps that turned on AllowsTransparency later.","solutions":["Set WindowStyle=\"None\" whenever AllowsTransparency=\"True\"","If a border is still wanted, draw a custom chrome/border inside the borderless transparent window","Alternatively drop AllowsTransparency if the standard window frame is required"],"exampleFix":"// before\n<Window AllowsTransparency=\"True\" WindowStyle=\"SingleBorderWindow\" />\n// after\n<Window AllowsTransparency=\"True\" WindowStyle=\"None\" />","handlingStrategy":"validation","validationCode":"if (window.AllowsTransparency && window.WindowStyle != WindowStyle.None) window.WindowStyle = WindowStyle.None;","typeGuard":null,"tryCatchPattern":"try { window.AllowsTransparency = true; } catch (InvalidOperationException) { window.WindowStyle = WindowStyle.None; window.AllowsTransparency = true; }","preventionTips":["Always pair AllowsTransparency=\"True\" with WindowStyle=\"None\" in XAML","Set WindowStyle before AllowsTransparency when configuring in code","Enforce the invariant in a helper that configures window chrome"],"tags":["wpf","window","allowstransparency","windowstyle","conflicting-properties"],"backgroundTag":"conflicting-config-options","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}