This is a migrated thread and some comments may be shown as answers.

Binding to CollectionViewSource not working

1 Answer 632 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Johannes asked on 06 Nov 2014, 03:30 PM
I want to bind a RadGridView and a RadDataForm to the same collection of items and they should synchronize like in your WPF demo application. When I bind the ItemsSource property directly to my ICollectionView property in the ViewModel everything works fine. But when I create a CollectionViewSource bound to that property and use this resource as ItemsSource both controls do not show the data. Why is that not possible? I want to add sorting and grouping and CollectionViewSource seems to be the right way. Here's my code:

01.<Window x:Class="WpfApplication1.MainWindow"
04.        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
05.        Title="MainWindow">
06.    <Window.Resources>
07.        <CollectionViewSource x:Key="MySource" Source="{Binding ItemsView}" />
08.    </Window.Resources>
09.    <Grid>
10.        <StackPanel>
11.            <StackPanel Orientation="Horizontal" Height="200" Margin="10">
12.                <!-- binding directly to property ItemsView in DataContext/ViewModel ... WORKING -->
13.                <telerik:RadGridView AutoGenerateColumns="True" ItemsSource="{Binding ItemsView}" Width="200" />
14.                <telerik:RadDataForm AutoGenerateFields="True" ItemsSource="{Binding ItemsView}" Width="200" />
15.            </StackPanel>
16.            <StackPanel Orientation="Horizontal" Height="200" Margin="10">
17.                <!-- binding to CollectionViewSource ... NOT working -->
18.                <telerik:RadGridView AutoGenerateColumns="True" ItemsSource="{Binding Source={StaticResource MySource}}" Width="200" />
19.                <telerik:RadDataForm AutoGenerateFields="True" ItemsSource="{Binding Source={StaticResource MySource}}" Width="200" />
20.            </StackPanel>
21.        </StackPanel>
22.    </Grid>
23.</Window>

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 07 Nov 2014, 04:13 PM
Hello,

CollectionViewSource.View returns ICollectionView which is a valid Source collection for RadGridView. 
Would it be possible for you to open a new support thread and send us a demo project illustrating the problem? You can take a look at this blog post for a reference on how to isolate an issue. 

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Johannes
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or