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
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