1

I'm trying implement DataGridVirtualizingQueryableCollectionViewSource like documentation: http://doc.xceedsoft.com/products/xceedwpfdatagrid/Xceed.Wpf.DataGrid.v4.5~Xceed.Wpf.DataGrid.DataGridVirtualizingQueryableCollectionViewSource.html
Using ObjectContext API everything is normal.
However when using DbContext API, the cells content aren't showed.
Does anyone know anything about this?

/// <summary>
/// WITH THIS WORKS.
/// </summary>
public partial class AdventureWorksEntities : ObjectContext 

/// <summary>
/// WITH THIS DOES NOT WORK.
/// </summary> 
public partial class AdventureWorksEntities : DbContext 

My source below:

<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
    <Grid.Resources>

        <xcdg:DataGridVirtualizingQueryableCollectionViewSource 
            x:Key="cvs_queryableSource"
            QueryableSource="{Binding Path=QueryableSource}"/>

    </Grid.Resources>
    <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource cvs_queryableSource}}">
    </xcdg:DataGridControl>
</Grid>

public partial class MainWindow : Window
{
    public MainWindow()
    {
        this.DataContext = this;
        InitializeComponent();
    }

    public IQueryable QueryableSource
    {
        get
        {
            if (m_queryable == null)
            {
                m_northwind = new AdventureWorksEntities();
                m_queryable = m_northwind.Contact;
            }
            return m_queryable;
        }
    }

    private AdventureWorksEntities m_northwind;
    private IQueryable m_queryable;
}

Thank you!

4

1 回答 1

1

我不知道为什么,但我的查询中的一个简单 OrderBy 解决了这个问题。

public IQueryable QueryableSource
{
    get
    {
        if (m_queryable == null)
        {
            m_northwind = new AdventureWorksEntities();
            m_queryable = m_northwind.Contact.OrderBy(p => p.SomeField);
        }
        return m_queryable;
    }
}

再次感谢!

于 2013-04-24T20:20:25.973 回答