WPF C# ICollectionView enumerating through items in a group

408 views Asked by At

UPDATE: So I created a IValueConverter which I access through a PropertyGroupDescription. I have managed some helpful things with it but have not been able to fix my issue.

My current problem is accessing the object type:

public object Convert(object value, Type targetType, object parameter, 
CultureInfo culture)
{
var obj = targetType as MyType // Error, can't convert to mytype
var obj = targetType as IGrouping<System.String, MyType>; // no error but returns null
...

Maybe I miss undastand what targettype is, but I can't do anything with it.

What I am trying to do is pass the grouped object, a IGrouping < System.String, MyType> to my converter, so I can loop through it to put the contained items into the correct groups via this line of code:

view.GroupDescriptions.Add(
    new PropertyGroupDescription(groupBy,
    new MyConverter()));

I would like the view to render like this on screen:

-------------- Group is true = true(2 items) --------------------

stack1 true and false (20 items)

stack3 only true (x items)

------------- Group is true = false( 2 items) ------------------

stack1 true and false (13 items)

stack2 only false (x items)


Currently it displays like this:

-------------- Group is true = true(2 items) --------------------

stack1 true and false (33 items)

stack3 only true (x items)

------------- Group is true = false( 1 item) ------------------

stack2 only false (x items)

0

There are 0 answers