wpf datagrid adding items synchronously
I have a WPF Datagrid on my project. When user uploads documents(or selects folder) into program datagrid is being loaded by the document's whole properties(text, type, uri etc.). Especially when user gives a folder to program it freezes for a time till it loads every folder. And on final step it populates the datagrid.
T开发者_JAVA百科he thing I really want to do is that loading datagrid rows as soon as a file is loaded successfully not at the end of the last process.
Could you show me some way..
Have you tried updating the DatGrid on a different thread?
here's an example of how it's done in WPF:
// Places the delegate onto the UI Thread's Dispatcher
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
// Place delegate on the Dispatcher.
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new TimerDispatcherDelegate(TimerWorkItem));
}
taken from msdn
精彩评论