locked
Loading data asynchronously and binding to DataGrid with ComboBox columns RRS feed

  • Question

  • Hi, I have table Orders with several columns, Manager and Customer are among them. I need to load data from Orders table and to load data from Managers and Customers tables to DataGridComboBox columns and set SelectedItemBinding for those columns.

    The problem is that I need to load all data asynchronously. So I can't put ItemsSource and SelectedItemBinding for ComboBox columns in xaml. I should set those properties in last completed quiery's OnQueryCompleted event handler.

    I did it. I'm checking for last completed quiery by setting boolean flags to each completed quiery and checking this flags in every OnQueryCompleted event handler before setting datacontext for datagrid, ItemsSource and SelectedItemBinding for ComboBox columns.

    But, often, when debugging, I have situation, when all items loaded into datagrid and comboboxes, but selected item (value) property of all ComboBoxes is empty. I.e., sometimes it loads correctly, sometimes no. I can't understand how to solve this problem.

    Btw, in previous implementation of this app, I was loading data in a classic way, and all bindings was working good. I was using ObjectDataProviders as ItemsSource for ComboBox columns.

    Saturday, July 3, 2010 2:36 PM

All replies

  • Solved. I just forgot to remove unnecessary Expands from one of quieries and I think they were in conflict with quieries on same tables.
    Sunday, July 4, 2010 9:09 AM