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

Binding Issue

5 Answers 109 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Trude
Top achievements
Rank 2
Trude asked on 07 Jul 2010, 08:01 PM
Let's say I have a simple class like this:
Public Class MyBaseClass  
    Implements INotifyPropertyChanged  
    Private _coord As Integer 
 
    Public Property coord() As Integer 
        Get 
            coord = _coord  
        End Get 
        Set(ByVal value As Integer)  
            _coord = value  
            RaiseEvent PropertyChanged(MeNew PropertyChangedEventArgs("coord"))  
        End Set 
    End Property 
 
    Public Event PropertyChanged(ByVal sender As ObjectByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged  
End Class 

I then have a class that essientially contains pointers to entities in the base class:
Public Class MyClass 
 
    Public Property coord_x As MyBaseClass  
    Public Property coord_y As MyBaseClass  
 
End Class 

Lastly I create an ObervableCollection of MyClass and my XAML looks like this:
.....  
<telerik:SeriesMapping.ItemMappings> 
    <telerik:ItemMapping DataPointMember="XValue" FieldName="coord_x.value"/>  
    <telerik:ItemMapping DataPointMember="YValue" FieldName="coord_y.value"/>  
</telerik:SeriesMapping.ItemMappings> 
.....  
                          
<TextBlock Text="{Binding coord_a.value}"/> 

When entities change in the base class the changes are reflected in the TextBlock, but not in the radchart (if I rebind the chart is updated). If the chart is attached directly to the base class (for testing purposes) all changes are reflected in the chart also.

Are there some limitations in your current implementation of radchart or is this a bug?

5 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 12 Jul 2010, 07:21 AM
Hi Jorn,

The base class does not have property named value, but one named coord. Binding should look like this:
<telerik:SeriesMapping.ItemMappings>  
    <telerik:ItemMapping DataPointMember="XValue" FieldName="coord_x.coord"/>   
    <telerik:ItemMapping DataPointMember="YValue" FieldName="coord_y.coord"/>   
</telerik:SeriesMapping.ItemMappings>  


Best wishes,
Joshua
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Trude
Top achievements
Rank 2
answered on 27 Sep 2010, 11:03 AM
Sorry, for the late reply. This was a typo on my behalf - of course it should be .coord instead of .value in the XAML code.
Anyway; the problem persists and the code is not working as I expect it to. The textblock updates dynamically, but the chart is not (I have to rebind it manually).
0
Evgenia
Telerik team
answered on 30 Sep 2010, 02:30 PM
Hello Jorn,

As you mentioned "If the chart is attached directly to the base class (for testing purposes) all changes are reflected in the chart also." Current version of RadChart doesn't provide item property changed notification so you should Rebind the Chart in order to have it updated. 
I hope this information helps.

Sincerely yours,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kjellerik
Top achievements
Rank 1
answered on 04 Oct 2010, 07:10 AM
Hi,

I have a problem similar to the one described. It started when i upgraded to telerik controls Q2 (2010.2.924) from version 2010.2.714.1040. The RadChart lost it capabilities to update when i use NotifyPropertyChanged, as it has before. 

<telerikChart:RadChart ItemsSource="{Binding KPIChartEntities}" x:Name="radChart" Grid.Column="1" Grid.Row="1" Margin="15,15,15,0" >
                <telerikChart:RadChart.DefaultView>
                    <charting:ChartDefaultView>
                        <charting:ChartDefaultView.ChartArea>
                            <charting:ChartArea x:Name="mainChart" EnableAnimations="False" EnableStripLinesAnimation="False" >
                                <charting:ChartArea.Annotations>
                                    <charting:CustomGridLine YIntercept="{Binding Target}"
                                                         Visibility="Visible"
                                                         Stroke="Red"
                                                         StrokeThickness="3" />
                                </charting:ChartArea.Annotations>                           
                                <charting:ChartArea.AxisX>
                                    <charting:AxisX  LabelRotationAngle="90">
                                    </charting:AxisX>
                                </charting:ChartArea.AxisX>
                                <charting:ChartArea.AxisY>
                                    <charting:AxisY Title="{Binding UnitName}">
                                    </charting:AxisY>
                                </charting:ChartArea.AxisY>
                            </charting:ChartArea>
                        </charting:ChartDefaultView.ChartArea>
                    </charting:ChartDefaultView>
                </telerikChart:RadChart.DefaultView>
             
                <telerikChart:RadChart.SeriesMappings>                               
                    <charting:SeriesMapping ChartAreaName="mainChart" x:Name="seriesMapping">                   
                        <charting:SeriesMapping.ItemMappings>
                            <charting:ItemMapping DataPointMember="XCategory" FieldName="XSubCategory" />
                            <charting:ItemMapping DataPointMember="YValue"  FieldName="YValue" />                          
                        </charting:SeriesMapping.ItemMappings>
                    </charting:SeriesMapping>
                </telerikChart:RadChart.SeriesMappings>
            </telerikChart:RadChart>

The KPIChartEntities is an ObservableCollection<KPIChartEntity>. KPIChartEntity contains a "void UpdateActual()" which updates a the YValue, and runs a NotifyPropertyChanged to get reflected in the chart. 

public virtual void UpdateActual(bool? isUChecked, bool? isDChecked, bool? isWChecked, bool? isWOWChecked)
        {
            double? lastValue = yValuePriv;
 
            double d = Convert.ToDouble(Actual);
            if (!Convert.ToBoolean(isUChecked))
                d -= Convert.ToDouble(U);
            if (!Convert.ToBoolean(isDChecked))
                d -= Convert.ToDouble(D);
            if (!Convert.ToBoolean(isWChecked))
                d -= Convert.ToDouble(W);
            if (!Convert.ToBoolean(isWOWChecked))
                d -= Convert.ToDouble(WOW);
            if (Length != null && Length != 0 && SumType != null && SumType.ToUpper().Equals("AVARAGE"))
                d = Convert.ToDouble(Length) / (d * 60);
            yValuePriv = d;
            if (yValuePriv != lastValue)
                NotifyPropertyChanged("YValue");
        }

Now at the older versions of Telerik, my chart got updated nicely when this method was executed. However with latest version, this does not happen. I also have a datagrid (telerik) which does reflects the changes done in UpdateActual method. Do i have to rewrite the program, so the chart rebind to the observablecollection every time a change occur, or is there any other way to do this?
0
Evgenia
Telerik team
answered on 07 Oct 2010, 09:25 AM
Hello kjellerik,

Version 2010.2.924 of RadChart doesn't provide item property changed notification so you should Rebind the Chart in order to have it updated.

Please let me know if other questions arise.

Regards,
Evgenia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Trude
Top achievements
Rank 2
Answers by
Dwight
Telerik team
Trude
Top achievements
Rank 2
Evgenia
Telerik team
kjellerik
Top achievements
Rank 1
Share this question
or