WPF为路径添加自定义工具提示

时间:2018-08-17 14:05:29

标签: wpf path tooltip shape

我正在画布中动态构建更多路径,我想添加一个工具提示,其中包含有关路径形状的更多详细信息。但是,似乎只有在我将路径点悬停时才会显示收费提示。当我将鼠标悬停在填充区域或其轮廓上时,我希望它也出现。

                PolyLineSegment polySeg = new PolyLineSegment(new Point[] { new Point(triangleX - 8, triangleY - 20), new Point(triangleX + 8, triangleY - 20) }, true);
                PathFigure pathFig = new PathFigure(new Point(triangleX, triangleY), new PathSegment[] { polySeg }, true);
                PathGeometry pathGeo = new PathGeometry(new PathFigure[] { pathFig });
                pathGeo.Transform = new RotateTransform(angleOfTheTriangleInGrades, triangleX, triangleY);

                Path path = new Path();
                path.Data = pathGeo;
                path.Fill = Brushes.Yellow;


                var sp = new StackPanel();
                sp.Children.Add(new TextBlock
                {
                    Text = "aaa"
                });

                sp.Children.Add(new Button
                {
                    Height = 20,
                    Width = 100,
                    Content = "bbbaaa"
                });

                path.ToolTip = sp;

                pathList.Add(path);

0 个答案:

没有答案