This is a migrated thread and some comments may be shown as answers.

dynamic create Series ,difficult to create TrackBallInfoTemplate

1 Answer 29 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Si
Top achievements
Rank 1
Si asked on 19 Oct 2018, 02:05 AM

     Chart.Series.Add(new LineSeries
     {
      CategoryBinding = binding,
      ValueBinding = ...,
      StrokeThickness = 1,
      Stroke = ...,
      ItemsSource = vm.Datas,
      TrackBallInfoTemplate = // difficult to create
     });

 

TrackBallInfoTemplate is difficult to create, how can i only set a stringformat to use trackballinfo

1 Answer, 1 is accepted

Sort by
0
Si
Top achievements
Rank 1
answered on 20 Oct 2018, 03:41 AM

OK, i can build it by code,

 

            var dataTemplate = new DataTemplate();
            var stackPanel = new FrameworkElementFactory(typeof(StackPanel));
            var textBlock = new FrameworkElementFactory(typeof(TextBlock));
            stackPanel.AppendChild(textBlock);
            dataTemplate.VisualTree = stackPanel;
            s.TrackBallInfoTemplate = dataTemplate;
            s.ApplyTemplate();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("DataPoint.Value") { StringFormat = LineName + " - {0:0}" });

Tags
ChartView
Asked by
Si
Top achievements
Rank 1
Answers by
Si
Top achievements
Rank 1
Share this question
or