WPF的工具提示实现方法如下

1:简单的工具提示只需设置元素的ToolTip属性

     example:

<Button Margin="20" Grid.Row="2" ToolTip="This is a button">
another button
</Button>

2:复杂的工具提示需要使用更复杂的嵌套内容设置ToolTip属性

example:

代码
<Window x:Class="grid_Study.MainWindow"
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
Title
="MainWindow" Height="350" Width="525" >
<Button Content="my button">
<Button.ToolTip>
<StackPanel>
<TextBlock Margin="3">Image and text</TextBlock>
<Image Source="C:\Users\Public\Pictures\Sample Pictures\baxianhua.jpg" Width="150" Height="150"/>
<TextBlock Margin="3">Image and text</TextBlock>
</StackPanel>
</Button.ToolTip>
</Button>
</Window>

3.工具提示的显示位置:

3.1 相对于鼠标的位置

WPF 工具提示(ToolTip)

3.2 相对于元素的侧边

WPF 工具提示(ToolTip)

3.3 相对于元素进行偏移

 WPF 工具提示(ToolTip)

4.设置ToolTipService属性

通过ToolTipService属性配置工具提示框显示的延迟时间

相关文章:

  • 2021-08-28
  • 2022-12-23
  • 2022-01-11
  • 2021-06-03
  • 2021-06-10
  • 2021-06-13
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-01-17
  • 2021-05-25
  • 2022-01-19
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
相关资源
相似解决方案