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

Binding ObservableCollection to ItemSource

1 Answer 161 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
kl
Top achievements
Rank 1
kl asked on 22 Nov 2012, 02:20 AM
What is the proper way of coding standard to bind the ObservableCollection to ItemSource?
The case i'm facing is i have multiple lineseries, therefore, i created an ObservableCollection<IEnumberable><T>> that contains array of ObservableCollection<T>. i make the ObservableCollection<IEnumberable><T>> binded to the itemsource of lineSeries with INotifyPropertyChanged.

Code Snippet:
XAML:
<chartView:LineSeries x:Name="Item1" ItemsSource="{Binding Item[0]}" ValueBinding="Value" CategoryBinding="Counter" />
<chartView:LineSeries x:Name="Item2" ItemsSource="{Binding Item[1]}" ValueBinding="Value" CategoryBinding="Counter" />
<chartView:LineSeries x:Name="Item3" ItemsSource="{Binding Item[2]}" ValueBinding="Value" CategoryBinding="Counter" />
<chartView:LineSeries x:Name="Item4" ItemsSource="{Binding Item[3]}" ValueBinding="Value" CategoryBinding="Counter" />
<chartView:LineSeries x:Name="Item5" ItemsSource="{Binding Item[4]}" ValueBinding="Value" CategoryBinding="Counter" />

C#
public ObservableCollection<IEnumerable<GraphPlot>> Item
{
      get { return m_item; }
      set
      {
           m_item = value;
           OnPropertyChanged("Item");
      }
}

i have an error "observablecollection collection was modified enumeration operation may not execute" using the code above.
is this the right way to bind it to multiple itemsource with only 1 Properties at real-time? any recommendation?

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 26 Nov 2012, 05:47 PM
Hi,

Given the information you've provided it is not possible to determine the cause of the problem. I have attached a test project, created using the code you provided. The project runs as expected. 

If the problem persists, please send more information, so we can track down the problem locally (you can open a support ticket and attach a project that reproduces this issue).
 
All the best,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
kl
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or