WPF: Tooltip on the fill of a Path

微笑、不失礼 提交于 2019-12-24 06:03:18

问题


I want to assign a tooltip to a System.Windows.Shape.Path.

While the tooltip pops up when I touch the outline of the path I get no tooltip when I am inside the filled part of the path.

Can I change this behavior in some way? My only idea was to add the path to an additional control like a canvas and assign the tooltip to the canvas. But that seems to be a lot of work.

Is there any other way?

EDIT: The path is and should be filled. The tooltip should popup on the path outline and on the filled area inside.


回答1:


If you are creating the path dynamically, you can set like this:

Path p = new Path();
........
.......
p.Fill = new SolidColorBrush(Colors.Red);
p.SetValue(ToolTipService.ToolTipProperty, "Tooltip is here");



回答2:


If you have not set the Fill property, the behavior you have is expected. Consider setting the Fill property to Transparent if you simply want an "outline" Path.

<Path Fill="Transparent" 
      ToolTip="My Tooltip" 
      Data="..." Stroke="..." StrokeThickness="..."  />


来源:https://stackoverflow.com/questions/6189468/wpf-tooltip-on-the-fill-of-a-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!