У меня есть необходимость создавать собственные всплывающие подсказки для точек данных в диаграммах WPF. Мне известно о решении для установки таких параметров в XAML, но мне нужно что-то динамическое, что можно изменить во время выполнения. В частности, я хочу отобразить значения для x, y и целочисленное значение (например, «x, y, 32»).
Следующий код демонстрирует, как создаются мои серии строк, и яЯ предполагаю, что любые настройки всплывающей подсказки будут помещены в этот метод.
Любая помощь будет оценена!
private LineSeries CreateLineSeries(string line, double pointSize, PolicyColors policyColors, bool fixedColors)
{
_log.Trace("");
Color color = (fixedColors) ? policyColors.GetFixedColor(line) : policyColors.GetDynamicColor(line);
Style pointStyle = new Style();
pointStyle.TargetType = typeof(LineDataPoint);
pointStyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(color)));
pointStyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Transparent)));
pointStyle.Setters.Add(new Setter(FrameworkElement.WidthProperty, pointSize));
pointStyle.Setters.Add(new Setter(FrameworkElement.HeightProperty, pointSize));
LineSeries lineSeries = new LineSeries();
lineSeries.Title = line;
lineSeries.DataPointStyle = pointStyle;
lineSeries.IndependentValueBinding = new Binding("X");
lineSeries.DependentValueBinding = new Binding("Y");
lineSeries.ItemsSource = new ObservableCollection<GraphControls.Point>();
return lineSeries;
}