How to refresh a WPF DataGrid?

前端 未结 7 1760
旧时难觅i
旧时难觅i 2020-12-14 07:15

I have a WPF DataGrid with some data. You can add rows through a separate window. The DataContext is the same, a LINQ-to-SQL object. Binding is also the same, I bind the \"I

7条回答
  •  佛祖请我去吃肉
    2020-12-14 07:28

    For some reason Items.Refresh() is not working for me. What did work was to make my underlying collection inherit ObservableCollection and then call its Add method.

    ((ContactUIObjects)dgrdContacts.ItemsSource).Add(new ContactUIObject(o));
    

    ContactUIObjects is just the grids underlying collection.

提交回复
热议问题