1

I'm doing currently some first Windows Phone 8 / XAML experiments and use the WinRTXamlToolkit chart control. While I managed to get my data drawn, I have problems to redraw the control to display changed data.

                CHART_Overview.Series.Add(_lsChartOvw);

            ((AreaSeries)CHART_Overview.Series[0]).ItemsSource = _lstLogOvw;

            LinearAxis dta = new LinearAxis();
            dta.Title = "X";
            dta.Orientation = AxisOrientation.X;
            dta.ShowGridLines = true;

            CHART_Overview.Axes.Add(dta);

            CHART_Overview.Axes.Add(new LinearAxis()
            {
                Minimum = 0,
                Maximum = 100,
                Orientation = AxisOrientation.Y,
                Interval = 20,
                ShowGridLines = true,
                Title = "Y"
            });

            Random rd = new Random((int)DateTime.Now.ToFileTimeUtc());

            for(int i = 0; i < 20; i++)
            {
                _lstLogOvw.Add(new GenericValueItem() { X = i, Y = rd.Next(1, 100) });
            }

I tried the following update scheme

                _lstLogOvw.Clear();
            for (int i = 0; i < 20; i++)
            {
                _lstLogOvw.Add(new GenericValueItem() { X = i, Y = rd.Next(1, 100) });
            }

            ((AreaSeries)CHART_Overview.Series[0]).ItemsSource = _lstLogOvw;

The list is of type ObservableCollection. It's probably a binding problem but I've not much XAML experience at the moment to fully understand the refresh mechanism.

Florian Storck
  • 509
  • 8
  • 22

1 Answers1

0

Don't know the proper way of doing it, but you can get around it by force the ItemSource to be null before assigning back to the actual list.

((AreaSeries)CHART_Overview.Series[0]).ItemsSource = null;
((AreaSeries)CHART_Overview.Series[0]).ItemsSource = _lstLogOvw;
t2o2
  • 345
  • 3
  • 11
  • I switched to SparrowChart because I needed something compatible with WinPhone 8, but I suppose your solution will do. I think I didn't try nulling the Source before reassigning, so I probably got no refresh. I think using an ObservableCollection would be the better solution. – Florian Storck May 05 '15 at 12:36
  • It works, but the lines changes color every time, how to avoid that? – Timur Sadykov Aug 15 '16 at 07:24