{"record":{"id":"0d8e648146b15e44","repo":"dotnet/wpf","slug":"by-default-tooltip-property-does-not-support-tooltip-element","errorCode":null,"errorMessage":"By default, ToolTip property does not support ToolTip element with StaysOpen set to false.","messagePattern":"By default, ToolTip property does not support ToolTip element with StaysOpen set to false\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PopupControlService.cs","lineNumber":460,"sourceCode":"                {\n                    _currentToolTip = new ToolTip();\n                    _currentToolTip.SetValue(ServiceOwnedProperty, BooleanBoxes.TrueBox);\n\n                    // Bind the content of the tooltip to the ToolTip attached property\n                    Binding binding = new Binding\n                    {\n                        Path = new PropertyPath(ToolTipService.ToolTipProperty),\n                        Mode = BindingMode.OneWay,\n                        Source = o\n                    };\n                    _currentToolTip.SetBinding(ToolTip.ContentProperty, binding);\n                }\n\n                if (!_currentToolTip.StaysOpen)\n                {\n                    // The popup takes capture in this case, which causes us to hit test to the wrong window.\n                    // We do not support this scenario. Cleanup and then throw and exception.\n                    throw new NotSupportedException(SR.ToolTipStaysOpenFalseNotAllowed);\n                }\n\n                _currentToolTip.SetValue(OwnerProperty, o);\n                _currentToolTip.Closed += OnToolTipClosed;\n                _currentToolTip.FromKeyboard = fromKeyboard;\n\n                if (!_currentToolTip.IsOpen)\n                {\n                    // open the tooltip, and finish the initialization when its popup window is available.\n                    _currentToolTip.Opened += OnToolTipOpened;\n                    _currentToolTip.IsOpen = true;\n                }\n                else\n                {\n                    // If the tooltip is already open, initialize it now. This only happens when the\n                    // app manages the tooltip directly.\n                    SetSafeArea(_currentToolTip);\n                }","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/PopupControlService.cs#L442-L478","documentation":"WPF's PopupControlService (which manages ToolTip display) does not support a ToolTip whose Popup-style StaysOpen is set to false. When StaysOpen is false the popup takes mouse capture, which breaks the hit-testing the tooltip service relies on to route input to the correct window. The service detects this and throws NotSupportedException instead of showing a broken tooltip.","triggerScenarios":"Setting ToolTip.StaysOpen=false on a ToolTip assigned via FrameworkElement.ToolTip or ToolTipService, then hovering the element so ShowToolTip promotes it to the current tooltip.","commonSituations":"Developers copying popup settings onto tooltips, or trying to force the tooltip to close on outside click by reusing Popup options that are valid for Popup but not for ToolTip.","solutions":["Remove StaysOpen=false from the ToolTip (leave it at the default true)","If you need click-outside-to-close behavior, use a Popup directly instead of ToolTip","Handle tooltip dismissal via the tooltip's Opened/Closed events or ToolTipService durations instead of StaysOpen"],"exampleFix":"// before\nvar tt = new ToolTip { Content = \"Help\", StaysOpen = false };\nbutton.ToolTip = tt;\n// after\nvar tt = new ToolTip { Content = \"Help\" };\nbutton.ToolTip = tt;","handlingStrategy":"validation","validationCode":"if (tooltip is ToolTip t && !t.StaysOpen) { t.StaysOpen = true; } // enforce before assigning to element.ToolTip","typeGuard":"static bool IsSupportedToolTip(ToolTip t) => t == null || t.StaysOpen;","tryCatchPattern":null,"preventionTips":["Never set StaysOpen=false on ToolTip objects","Use Popup (not ToolTip) when you need capture-based dismissal behavior","Centralize tooltip creation in a factory that enforces StaysOpen=true"],"tags":["wpf","tooltip","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"}