How to Programmatically show a WPF/C# Windows.Control.ToolTip?

后端 未结 7 2025
温柔的废话
温柔的废话 2020-12-25 12:01

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

相关标签:
7条回答
  • 2020-12-25 13:01

    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 need ToolTip.Show() if you write ToolTip="" in your XAML code (of the control for which you want the ToolTip) before the ToolTipOpening event in that control's XAML. For example, for a Button control:

    <Button Name="exampleButton" Content="example" ToolTip="" ToolTipOpening="example_ToolTipOpening"/>
    

    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 the ToolTip="")

    Hope this helps.

    0 讨论(0)
提交回复
热议问题