开发者

Don't show Data in DataGrid

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜