问题
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