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

Problem when changing binded data

2 Answers 46 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Benoît
Top achievements
Rank 1
Benoît asked on 26 May 2014, 09:13 PM
Hello,

Sorry for crossposting, I originally put this in the UI for Windows Phone 7 section but I'm using UI for Windows Phone 8 so I'll repost hhere.

I currently have designed a chart page in my application, which uses a SplineAreaSeries. I use MVVM with Caliburn.Micro, and I have a date picker in my chart page which allows the user to  chose the date corresponding to the chart data which will be displayed.
Currently my page only works on first loading (graph is displayed). When I change the date, the chart still displays the same data. It never changes. When going into debug I can see that the binded property in the ViewModel has been updated with correct data, it just doesn't displays.

Here is my code in the ViewModel :

private List<MeasureModel> _measures;
  
        public List<MeasureModel> Measures
        {
            get
            {
                return _measures;
            }
            set
            {
                _measures = value;
                NotifyOfPropertyChange(() => Measures);
            }
        }


Here is my data class :

public class MeasureModel
{
    public DateTime Time { get; set; }
    public double Value { get; set; }
  
    public MeasureModel(DateTime time, double value)
    {
        Time = time;
        Value = value;
    }
}


And here is my XAML code :

<chart:RadCartesianChart x:Name="Chart"
                                     Margin="12,12,12,12"
                                     Grid.Row="0" >
                <chart:RadCartesianChart.VerticalAxis>
                    <chart:LinearAxis />
                </chart:RadCartesianChart.VerticalAxis>
                <chart:RadCartesianChart.HorizontalAxis>
                    <chart:DateTimeContinuousAxis LabelFormat="HH:mm"
                                                  Minimum="00:00"
                                                  Maximum="23:59"
                                                  MajorStepUnit="Hour"
                                                  MajorStep="2"/>
                </chart:RadCartesianChart.HorizontalAxis>
                <chart:SplineAreaSeries ItemsSource="{Binding Measures}"
                                        CategoryBinding="Time"
                                        ValueBinding="Value"
                                        Fill="#FFD9EAFF"
                                        Stroke="CadetBlue"/>
            </chart:RadCartesianChart>


I don't see where I'm wrong. I tried with ObservableCollection, it didn't work. I tried accessing directly to the SplineAreaSeries element and assigning its ItemsSource property to my "Measures" property, it didn't change. It's just like there is no refresh of the display ... Though there is since sometimes the axis legends change a bit.

Can someone help me on this issue ? I'm running out of ideas :/

2 Answers, 1 is accepted

Sort by
0
Benoît
Top achievements
Rank 1
answered on 27 May 2014, 09:25 PM
I just tried to look at the DataPoints of the SplineAreaSeries element, and it seems to be correctly updated. Don't understand what's going on, is there a way to force a redraw ?
0
Rosy Topchiyska
Telerik team
answered on 29 May 2014, 08:44 AM
Hello Benoît,

Thank you for writing.

Your MeasureModel class has to implement the INotifyPropertyChanged interface in order to notify the chart that the data has been changed.

I hope this helps. Please, let us know if you have further questions.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
Benoît
Top achievements
Rank 1
Answers by
Benoît
Top achievements
Rank 1
Rosy Topchiyska
Telerik team
Share this question
or