将TextBlock放在wpf(C#)中的ToolTip中

时间:2018-06-04 05:55:14

标签: c# wpf tooltip textblock mousehover

for(int k=0;k<Config.Lines[i].Config.Stations[j].Config.Backward.Count;k++){

                _drawing.Children.Add(new Ellipse
                {   ToolTip = "Add your tooltip text here",
                    Stroke = Brushes.Black,
                    StrokeThickness = .6,
                    Width = 3,
                    Height = 3,
                    Margin = new Thickness(Config.Lines[i].Config.Stations[j].Config.Coordinate.Item1, Config.Lines[i].Config.Stations[j].Config.Coordinate.Item2+PlatformGap*(-k), 0, 0)
                });
                }

如何将此文本块放在工具提示中?目的是仅在鼠标悬停时查看此文本块。如果您找到其他方法,请另外建议。

1 个答案:

答案 0 :(得分:-1)

Ellipse有一个可以使用的工具提示属性:

 _drawing.Children.Add(new Ellipse { ToolTip = "Add your tooltip text here", Fill = Brushes.Black, Stroke = Brushes.Black, StrokeThickness = .6, Width = 3, Height = 3, Margin = new Thickness(Config.Lines[i].Config.Stations[j].Config.Coordinate.Item1, Config.Lines[i].Config.Stations[j].Config.Coordinate.Item2+PlatformGap*(-k), 0, 0) }); }