如何编程方式显示一个WPF / C#Windows.Control.ToolTip?方式、WPF、Windows、Control

2023-09-03 01:51:52 作者:Absurd [荒谬]

似乎没有成为一个.Show()种方法为Windows.Control.ToolTip,包括在ToolTipService。任何想法?

There doesn't seem to be a .Show() kind of method for the Windows.Control.ToolTip, incl in ToolTipService. Any ideas?

谢谢!您的帮助。 : - )

Thanks! For your help. :-)

推荐答案

您需要做的就是确保在控制工具提示的类型为工具提示。然后你就可以将IsOpen属性设置为true,像这样:

What you need to do is make sure the ToolTip on the control is of type ToolTip. Then you can set the IsOpen property to true like so:

ToolTip tooltip = new ToolTip{ Content = "My Tooltip" };
NameTextBox.ToolTip = tooltip;
tooltip.IsOpen = true;