AidanH
AidanH

Reputation: 522

Xceed datagrid - Get current data

I've got an 'XceedDataGridWrapper' in an application which is bound to some data. In the C# file behind the XAML for the file which holds my dataset I have a variable which holds a reference to the Xceed data-grid:

public XceedDataGridWrapper GridWrapper;

Is there a simple method of getting all of the content that is currently visible on the grid (so if a user applies a filter of some kind, it will return only the items that are being shown)?

In the ideal world I'd like to be able to something similar to this:

var dataContext = GridWrapper.CurrentItems;

But I don't clearly see a method anywhere to do that.

Help is appreciated!

Upvotes: 1

Views: 330

Answers (1)

AidanH
AidanH

Reputation: 522

It turns out that 'XceedDataGridWrapper' has a 'CollectionViewSource' in it (thanks for the pointer @jsanalytics), however it was stored in a private property called 'mviewsource' So what I did was expose it as a dependency property:

public static readonly DependencyProperty CurrentDataProperty =
        DependencyProperty.Register(
            "CurrentData",
            typeof(DataGridCollectionView),
            typeof(XceedDataGridWrapper),
            new UIPropertyMetadata(null));

public DataGridCollectionView CurrentData
{
    get { return mviewSource; }
}

And then I could access the 'CollectionView' from outside the 'XceedDataGrid'.

Upvotes: 1

Related Questions