Hey, I'm trying to automatically add new records to DataGrid. Everything works, but the DataGrid is refreshing every time. I want to keep it unchanged, only if a new record comes in, I want to add it
public class Example{ public static ObservableCollection<T> exampleObs = new ... public void Method() bool help = true; do{ exampleObs.Add(new T(...)); }while(!help); }
public class XAMLWindow{ private readonly object exampleLock = new object(); public XAMLWindow{ InitializeComponent(); BindingOperations.EnableCollectionSynchronization(Example.exampleObs, exampleLock); lock (exampleLock) { //DataGridTable.ItemsSource = Example.exampleOb; Example ex = null; for (int i = 0; i < Example.exampleOb.Count; i++) { ex = Example.exampleOb[i]; DataGridTable.Items.Add(ex); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)