开发者

Don't show Data in DataGrid

开发者 https://www.devze.com 2022-12-31 20:04 出处:网络
in my app, I used WCF Services for load data from SQL DB then in Completed Event Handler of my ServiceClient write this code:

in my app, I used WCF Services for load data from SQL DB then in Completed Event Handler of my ServiceClient write this code:

void svc_GetOrdersCompleted(object sender, GetOrdersCompletedEventArgs e)
{
    if (e.Error == null)
    {
         dgOrders.ItemsSource = e.Result;
         txtStatus.Text = "";
    }
    else
         txtStatus.Text = "Error occured while loading orders from database";
}

dgOrders is my DataGrid and And AutoGenerateColumns set to True. in line 5: eResult have a number of Order objects but after this code DataGrid can't show data. Why?

this ia my xaml for dgOrders:

   开发者_如何学编程 <data:DataGrid x:Name="dgOrders"
                   Grid.Row="0"
                   Grid.Column="1"
                   AutoGenerateColumns="True"
                   SelectionChanged="dgOrders_SelectionChanged" Foreground="Green">
    </data:DataGrid>

this is my Source code please guide me.


First - do e.Result contains any data ? For more help you really need to share more info.

here a sample project where that scenario works fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号