DataGrid ItemsSource is bound 2 times

Nov 8, 2010 at 12:44 PM

Hello, can't find a solution, so I ask here.


I have a model class MyClassA with getter and setter properties, one of these properties is an ObservableCollection<MyClassB> bCollection holding items of an other own type MyClassB. The model itself is used in XAML like this:

  <model:MyClassA x:Key="classA" />

Now I am trying to set the ItemsSource property of a DataGrid. I haven't found, how to get it through a binding of classA as a StaticResource - is it possible? So I set the DataGrid's DataContext to bCollection in code-behind and my XAML looks like this:

<DataGrid ItemsSource="{Binding}" >
    <DataGridTemplateColumn Header="Year">
          <TextBlock Text="{Binding Year}" />

And I see the data from bCollection , but I get it twice - first time in my defined DataGrid.Columns and then all MyClassB properties are shown as columns again...