可以将List<Ellipse> markers;修改为:List<TextBox> markers;,并修改SetMarkerPosition()方法,设置TextBox的Text属性:
- void SetMarkerPosition(Point pt)
- {
- double dis1;
- for (int i = 0; i < markers.Count; i++)
- {
- int p = chart.View.DataIndexFromPoint(pt, i, MeasureOption.X, out dis1);
- Point ps1 = chart.View.DataIndexToPoint(i, p);
- markers[i].Text = String.Format("Y={0}", ps1.Y);
- Canvas.SetLeft(markers[i], ps1.X - markers[i].Width / 2);
- Canvas.SetTop(markers[i], ps1.Y - markers[i].Height / 2);
- }
- }
复制代码 |