DataGrid不显示任何内容(WCF-RIA)

时间:2011-01-12 19:29:45

标签: ria wcf-ria-services

这是我的网页代码:

    OrganizationContext ctx = new OrganizationContext();

    public EmployeeList()
    {
        InitializeComponent();
        ctx.Load(ctx.GetEmployeesQuery(), LoadBehavior.MergeIntoCurrent, EmployeesLoaded, null);
    }

    private void EmployeesLoaded(LoadOperation lo)
    {
        dataGrid1.ItemsSource = lo.Entities;
    }

回调执行,LoadOperation.Entities.Count为291,但由于某种原因,网格不显示任何内容。顺便说一句,我已经尝试设置DataContext属性,但仍然无法正常工作。

1 个答案:

答案 0 :(得分:1)

1,使你的DataGrid的属性AutoGenerateColumns =“True”; 代码应该是第二个:

OrganizationContext ctx = new OrganizationContext();
public EmployeeList()
{
    InitializeComponent();
    LoadOperation lo=ctx.Load(ctx.GetEmployeesQuery());
    dataGrid1.ItemsSource = lo.Entities;
}