Using CollectionViewSource to wrap my ItemsSource
My SfDataGrid works great with this binding: ItemsSource="{x:Bind MainModel.UngroupedMusicList}"
But when I try to define the binding inside a CollectionViewSource
<CollectionViewSource x:Name="UngroupedMusicListSource" Source="{x:Bind MainModel.UngroupedMusicList}" IsSourceGrouped="False" />
I've tried various ways and none of them work.
ItemsSource="{Binding Source={StaticResource UngroupedMusicListSource}}" <== this works for a gridview
ItemsSource="{x:Bind {StaticResource UngroupedMusicListSource}}
ItemsSource="{StaticResource UngroupedMusicListSource}"
How can I make this work with the CollectionViewSource?
SIGN IN To post a reply.
5 Replies
JS
Jayapradha S
Syncfusion Team
April 7, 2016 04:03 AM UTC
Hi Deanna,
Thank you for contacting Syncfusion Support.
We have analyzed your query. We have tried this same and binding the ItemsSource for SfDataGrid with CollectionViewSource. This retrieves the source as ComObject. So that it is not working in SfDataGrid.
Could you please share the details what is your requirement and why are using CollectionViewSource source as ItemsSource?
Regards,
Jayapradha
Thank you for contacting Syncfusion Support.
We have analyzed your query. We have tried this same and binding the ItemsSource for SfDataGrid with CollectionViewSource. This retrieves the source as ComObject. So that it is not working in SfDataGrid.
Could you please share the details what is your requirement and why are using CollectionViewSource source as ItemsSource?
Regards,
Jayapradha
DD
Deanna Delapasse
April 7, 2016 11:32 AM UTC
Hi Jaypradha!
Could you take a look at http://www.codeproject.com/Articles/1081343/Implementing-Windows-GridView-for-UWP-Apps ? They have both a GroupedMusicList & an UnGroupedMusicList. I can make the UnGrouped work in SfDataGrid, but NOT the Grouped.
They talk about the importance of setting the IsSourceGrouped="True" flag in the CollectionViewSource, but since I can't use that in SfDataGrid I hope there is another way to point the grid at the correct data.
thanks,
Deanna
JS
Jayapradha S
Syncfusion Team
April 8, 2016 01:07 PM UTC
Hi Deanna,
Thank you for your update.
We can understand your requirement. You can achieve it simply by setting the flag from your application like setting IsSourceGrouped in collectionviewsource.
We have prepared a simple sample for your requirement. Here, we have created a property named as IsSourceGrouped and when you setting the flag to true, you can view the grouped items in grid based on prodcutID values. you can add the group column description based on IsSourceGrouped flag like below
Code Example:
Please find the sample from the following location,
Sample Link: http://www.syncfusion.com/downloads/support/forum/123635/ze/SfDataGrid_SourceGrouped267073851
Regards,
Jayapradha
Thank you for your update.
We can understand your requirement. You can achieve it simply by setting the flag from your application like setting IsSourceGrouped in collectionviewsource.
We have prepared a simple sample for your requirement. Here, we have created a property named as IsSourceGrouped and when you setting the flag to true, you can view the grouped items in grid based on prodcutID values. you can add the group column description based on IsSourceGrouped flag like below
Code Example:
|
private bool isSourceGrouped = false;
public bool IsSourceGrouped { get { return isSourceGrouped; } set { isSourceGrouped = value; OnPropertyChanged("IsSourceGrouped"); } } private void Sfgrid_Loaded(object sender, RoutedEventArgs e) { if (viewModel != null && viewModel.IsSourceGrouped) sfgrid.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = "ProductID" }); |
Please find the sample from the following location,
Sample Link: http://www.syncfusion.com/downloads/support/forum/123635/ze/SfDataGrid_SourceGrouped267073851
Regards,
Jayapradha
DD
Deanna Delapasse
April 8, 2016 01:56 PM UTC
Jayapradha,
That is perfect! This actually solves my other issue as well, so you can close that one.
Thank you so much.
Deanna
JS
Jayapradha S
Syncfusion Team
April 11, 2016 06:35 AM UTC
Hi Deanna,
Thank you for your update. We are glad to know that your requirement has been met.
Regards,
Jayapradha
Thank you for your update. We are glad to know that your requirement has been met.
Regards,
Jayapradha
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
DD Deanna Delapasse
- Apr 5, 2016 05:26 PM UTC
- Apr 11, 2016 06:35 AM UTC