There doesn't seem to be a .Show() kind of method for the Windows.Control.ToolTip, incl in ToolTipService.
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
Is showing a tooltip what you really want to do. A tooltip has a clear meaning to most users and an expectation that it goes away when moving the mouse (and can come back when you hover over the item in question).
If your aim is to draw attention to something, have you considered some form of floating box which is fully under your control, WPF makes this easy!
Check out the
IsOpen
property in theToolTipService
class.Finally i ended with this .. and it's working fantastic ..
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.Show()
is available for Windows Forms, not for WPF controls. For WPF, if you simply want to display the ToolTip when the mouse enters the area of the control, you shouldn't needToolTip.Show()
if you writeToolTip=""
in your XAML code (of the control for which you want the ToolTip) before theToolTipOpening
event in that control's XAML. For example, for a Button control:The ToolTip should then be displayed automatically every time the mouse enters the area of that control. (You can set which text to display in the ToolTipOpening event function. Or you can omit the
ToolTipOpening
and set the text in the quotation marks of theToolTip=""
)Hope this helps.
If you would like to control how long the tooltip remains open, you can subscribe to the
Opened
event and set a time delay before closing the tooltip.Subscription has to be done before
IsOpen = true
and it has to be an async method to avoid hanging up the UI.