Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
ObservableCollection Binding to DataGrid.
posted

Hi EveryOne,

                      I am trying to TwoWay DataBind to my xamdatagrid with ObservableCollection. Its working fine to display data but its not allowing me to add new record in it and its the same case for generic List as well. Where if I use BindingList only then its enable me to add new record in my grid. Can any one know about the isse why is it so ? and if I want to use ObservableCollection to bind my xamdatagrid then please suggest me the solution that how can I achieve this functionality.

 

Thanks.

  • 69686
    Suggested Answer
    posted

    Hello,

    The AddNewRecord functionality is exposed through the IBindingList interface, so the underlying source collection should implement this interface. You can either derive from ObservableCollection and implement IBindingList or wrap the ObservableCollection into a collection view , like ListCollectionView,like this:

    ObservableCollection<String> source = new ObservableCollection<string>();

    ListCollectionView view = new ListCollectionView(source);