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

Finding all view models of group

2 Answers 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Sep 2010, 05:00 PM
I am using the MVVM design pattern and am attempting to add a button to perform an action on all items in a group. I have successfully added the button to the group header template and am attempting to find the view models of the group's rows with the following code:

private void validateGroupButton_Click(object sender, RoutedEventArgs e)
        {
            var sourceUIElement = (UIElement)sender;
            var group = sourceUIElement.ParentOfType<GridViewGroupRow>();
            var collectionViewGroup = (CollectionViewGroup)group.DataContext;
            var grid = sourceUIElement.ParentOfType<RadGridView>();
            var vm = (ManualDealsViewModel)grid.DataContext;
            var toValidate = collectionViewGroup.Items.Cast<ManualDealViewModel>().ToList();
              (.... perform action on toValidate enumeration ...)
            }

This basically works, however the toValidate enumeration only contains the rows that are currently visible in the group. 

Is there a way to retrieve all the view models that match the group, even if they are not presently visible?

2 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 06 Sep 2010, 03:03 PM
Hi David,

you should be able to get all items using collectionViewGroup.Items. I have prepared a sample application which demonstrates that all items can be retrieved using this property. I hope I have understood your question correctly.


Regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 06 Sep 2010, 04:17 PM
Thanks, that's done the job.
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Milan
Telerik team
David
Top achievements
Rank 1
Share this question
or