This is my code :
public void AddToGrid(string value)
{
MessageBox.Show(value); //Message is showing with correct value
dgrComponentList.Dispatcher.Invoke(new AddToGridDelegate(AddToGridSolid), System.Windows.Threading.DispatcherPriority.Normal, value);
}
private delegate void AddToGridDelegate(string value);
private void AddToGridSolid(string value)
{
((List<object>)this.dgrComponentList.ItemsSource).Add(new { ComponentName = value });
}
This not is not working when I am calling AddToGrid method from a thread.
But without thread if I am calling
((List<object>)this.dgrComponentList.ItemsSource).Add(new { ComponentName = value });
its working perfectly. Where am I doing wrong ?
Thanks
EDIT: I have just discovered, values are storing there but somehow its not showing into the grid.
The grid did not know that there is a new object added to the collection. Either implement an inotify collection changed or use an observable collection to store the objects.