// New up the series and add to chart
var series = new FastScatterBitmapSeries();
chart.Series.Add(series);
// Series Data Binding
series.ItemsSource = plotPoints;
series.XBindingPath = "X";
series.YBindingPath = "Y";
series.ScatterHeight = 4;
series.ScatterWidth = 4;
// Series Tooltips
series.ShowTooltip = true;
var template = new DataTemplate();
var txtblock = new FrameworkElementFactory(typeof(TextBlock));
txtblock.SetValue(TextBlock.WidthProperty, 85.0);
txtblock.SetValue(TextBlock.HeightProperty, 25.0);
txtblock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
txtblock.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
txtblock.SetValue(TextBlock.FontSizeProperty, 15.0);
var binding = new Binding();
binding.Path = new PropertyPath("ToolTip"); // This works for YData but how do I bind it to a custom ToolTip text
txtblock.SetValue(TextBlock.TextProperty, binding);
FrameworkElementFactory grid = new FrameworkElementFactory(typeof(StackPanel));
grid.AppendChild(txtblock);
template.VisualTree = grid;
series.TooltipTemplate = template;
=============================================
=============================================
private class PlotPoint
{
public PlotPoint(double x, double y, string toolTip=null)
{
X = x;
Y = y;
ToolTip = toolTip;
}
public double X { get; set; }
public double Y { get; set; }
public string ToolTip { get; set; }
}
=============================================
Model.CS public class Model { public double XValue { get; set; } public double YValue { get; set; } public string IDNum { get; set; } } Tooltip text Binding var binding = new Binding(); binding.Path = new PropertyPath("Item.IDNum"); //corresponding model of the fast scatter as Item txtblock.SetValue(TextBlock.TextProperty, binding); |