0
私は、1つのラインシリーズに対してカスタムツールチップを実行することに関するいくつかの質問を見てきました。wpfツールキットのlineseriesグラフの個々のデータポイントごとにツールチップをカスタマイズするには?
データポイントごとにカスタムツールチップが必要です。私は、依存値のパスと独立した値のパスだけではなく、ツールチップに多くを追加したいと思います。
例Iは、2016年4月28日の2つの値と同じ行1(Y軸)2の 上のデータポイント、日付(x軸)を有し、そしてAの構成の他は有しています の値3、2014年4月29日の日付、およびBの構成。
設定をどのように表示しますか?これは、私がラインナリーの動的な数を持っているので、コードの中ですべて行われます。だから私はxamlの各ラインリストにスタイルを割り当てるだけではいけません。
var MyLineSeries = new LineSeries();
lMyLineSeries.DependentValuePath = "Y";
lMyLineSeries.IndependentValuePath = "X";
lMyLineSeries.DataPointStyle = lToolTipDataPointStyle;
これは私のツールチップスタイルを作成するためのコードです。
var lToolTipDataPointStyle = new Style(typeof(LineDataPoint));
var lTemplate = new ControlTemplate(typeof(LineDataPoint));
var lGridElement = new FrameworkElementFactory(typeof(Border));
//Tooltip
var lStackPanel = new StackPanel();
var lValueContentControl = new ContentControl();
lValueContentControl.SetBinding(ContentControl.ContentProperty, new Binding(myLineSeries.DependentValuePath));
lValueContentControl.ContentStringFormat = "Value: {0}";
var lConfigurationContentControl = new ContentControl();
lConfigurationContentControl.SetBinding(ContentControl.ContentProperty, new Binding())//This is what Idk what to bind to???
lConfigurationContentControl.ContentStringFormat = "Configuration: {0}";
lStackPanel.Children.Add(lValueContentControl);
lStackPanel.Children.Add(lConfigurationContentControl);
lGridElement.SetValue(ToolTipService.ToolTipProperty, lStackPanel);
var lEllipseElement = new FrameworkElementFactory(typeof(Ellipse));
lEllipseElement.SetValue(Ellipse.StrokeThicknessProperty, new TemplateBindingExtension(Border.BorderThicknessProperty));
lEllipseElement.SetValue(Ellipse.StrokeProperty, new TemplateBindingExtension(Border.BorderBrushProperty));
lEllipseElement.SetValue(Ellipse.FillProperty, new TemplateBindingExtension(Grid.BackgroundProperty));
lGridElement.AppendChild(lEllipseElement);
lTemplate.VisualTree = lGridElement;
var lTemplateSetter = new Setter();
lTemplateSetter.Property = LineDataPoint.TemplateProperty;
lTemplateSetter.Value = lTemplate;
lToolTipDataPointStyle.Setters.Add(lTemplateSetter);
return lToolTipDataPointStyle;
_データポイントごとにカスタムツールチップが必要です._ツールチップの違いはどういう意味ですか?正確には何が変わっていますか?情報そのものや構造だけ?例を挙げる。 – jsanalytics
たとえば、表示したいのは 'X'、' Y'、 'Config'だけですが、' DataPointStyles'は必要ありません。それはちょうど異なるデータで同じスタイルです。この場合、XAMLを使用して行う必要があります。 – jsanalytics
ありがとう@jstreet私は質問を投稿した直後に方法を実際に考え出しましたが、返信する時間がありませんでした。しかし、入力をありがとう。 – mattyb