S
S
skvoshiz2017-03-28 19:11:01
.NET
skvoshiz, 2017-03-28 19:11:01

How to make DataGrid.DataContext binding without freezing UI thread (C# WPF .NET 4.5)?

Greetings to all, maybe someone has encountered such a problem, because I can’t solve it =( I did
everything according to the instructions: https://metanit.com/sharp/wpf/21.1.php
I do not bind data to a ListBox, as in the example, and to the DataGrid:

DataGridMark.DataContext = db.AccountsMark.Local.ToBindingList();

And at this moment I have a UI freeze.
And with further changes, like:
db.AccountsMark.Add(acc);
await db.SaveChangesAsync();

I get UI freeze too.
As I understand it, this is due to the fact that the binding is not done asynchronously.
Question:
How to bind asynchronously, or what to do so that there are no UI freezes when changes occur in db.AccountsMark

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2017-03-29
@yarosroman

I recommend reading about MVVM, then you will understand how to make bindings correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question