This is a migrated thread and some comments may be shown as answers.

No data appears in grid at startup

1 Answer 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andras
Top achievements
Rank 1
Andras asked on 20 Mar 2012, 12:42 PM
Hi,

I have a gridview, and its itemsSource is bound to an ObservableCollection in the ViewModel, and the isBusy property is also bound to a property there. Initially the collection is empty. In the constructor of the ViewModel I initiate a new thread which does the data collection from the DB. When the thread starts, it sets the isBusy property to true and triggers a notification, so the grid displays the loading animation. When the data is collected, the grid is notified again, and it displays the data. At the beginning the query which collected the data ran for 10+ seconds, and everything worked fine. But the query was optimized, so now it runs for less then a second, and here comes my problem: at startup for some reason I have no data displayed in the grid. The pager displays correct data, everything is fine except there is nothing in the grid. If I go to the second page, the data appears, and from that point everything works fine again.

I guess that my problem is related with the worker thread I create and the PropertyChanged notification, but I have no idea how to make it work. One more detail: if I put a Thread.Sleep(1000) before the PropertyChanged notification, everything works as expected. But this is not a nice way to solve the problem.

Any ideas how to make it work?

Thanks,

Andras

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Mar 2012, 01:35 PM
Hello Andras,

I believe the only way we can help here is to elaborate on a small runnable repro project. To be able to attach a project you may need to open a support ticket. ( please mention this thread inside the ticket) .

Regards,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Andras
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or