Home Forums WPF controls Xceed DataGrid for WPF Dynamic Binding of an Enumerable Collection

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #26869 |

    Hi everyone,

    I have set the ItemSource property to an Enumerable Collection (which is changing dynamically by our Entity-Framework).
    I have created the columns manually (because I want to show only a subset of the data).
    At first, the data is displayed according to the enumerable. When I change something via the DataGrid, it doesn’t update the enumerable member. Only when I sort (or move) the columns, the enumerable gets its update.
    The same happens in the opposite direction – if the collection changes, it only updates the DataGrid when re-sorting or moving the columns seperator.

    I would like to have dynamic-binding, i.e. update the collection whenever our user changes something through the DataGrid, and update the DataGrid whenever our collection changes.


    <Xceed:DataGridControl x:name=”DataGrid1″ AutoCreateColumns=”False”/>


    (note: enumrable1 = IEnumrable from entity framework, columnsDetails = names of columns that should be used)

    DataGrid1.ItemsSource = enumrable1;

     foreach (var x in columnsDetails) { DataGrid1.Columns.Add(new Column(x.PropertyName, x.Header, null);}


    Imported from legacy forums. Posted by Assaf (had 761 views)

    Xceed Support
    Post count: 5658


      For the DataGridControl to receive change notifications from the Data Source, the Data Source needs to implement either IBindingList or INotifyCollectionChanged. I also recommend encapsulating the Data Source within a DataGridCollectionView to benefit from several optimizations made ( grouping, sorting, insertion, … ).

      For the DataGridControl to receive change notifications from the elements within the Data Source, the elements need to implement INotifyPropertyChanged or use DependencyProperties (through base class DependencyObject).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 2766 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.