We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Binding collectionviewsource to datagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

118223 Feb 12,2015 06:54 AM Feb 13,2015 06:43 AM WinRT 1
loading
Tags: SfDataGrid
anna
Asked On February 12, 2015 06:54 AM

Hello!

How to bind CollectionViewSource to Datagrid? Because I've tried some things but no data is displayed.

Example:

    <Page.Resources>
        <ResourceDictionary>
            <CollectionViewSource x:Name="SampleDataViewSource" />         
        </ResourceDictionary>
    </Page.Resources>    


 <Grid:SfDataGrid Name="SampleGrid" Margin="0" 
                             ItemsSource="{Binding SampleDataViewSource}"                           
                             AutoGenerateColumns="False"
                             ColumnSizer="Auto">
                <Grid:SfDataGrid.Columns>
                    <Grid:GridTextColumn HeaderText="ID" MappingName="id" />
                    <Grid:GridTextColumn HeaderText="Customer" MappingName="name" />
                    <Grid:GridTextColumn HeaderText="Country" MappingName="country" />               
                </Grid:SfDataGrid.Columns>
            </Grid:SfDataGrid>


However if I bound this CollectionViewSource to GridView, data is displayed.

Thanks un advance

Regards
Anna

Mohanraj Gunasekaran [Syncfusion]
Replied On February 13, 2015 06:43 AM

Hi Anna,

Thanks for contacting Syncfusion support,

We have analyzed your query and we don’t have support to bind CollectionViewSource. Instead of that, you can bind GridQueryableCollectionViewWrapper of SfDataGrid which is derived from ICollectionView. Please refer the code snippet and sample in below location.

Code snippet:

this.datagrid.ItemsSource = new GridQueryableCollectionViewWrapper(new ViewModel().Source1, this.datagrid);

Sample location: http://www.syncfusion.com/uploads/user/directTrac/118223/VeticalAlignment-1142284013.zip

If the above solution doesn’t meet your requirement, Please let us know why do you need to bind CollectionViewSource. That will help us to provide better solution.

Please let us know if you have any further assistance,

Regards,

Mohanraj.



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;