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

Select added item and expand it's group

2 Answers 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Trude
Top achievements
Rank 2
Trude asked on 28 Nov 2012, 01:02 PM
I have a gridview with a group defined like so:
Dim group As New GroupDescriptor With {.Member = "name"}
group.AggregateFunctions.Add(New CountFunction With {.ResultFormatString = "({0:d})"})
GridView1.GroupDescriptors.Add(_group)

This code is executed each time the datacontext changes and the oldvalue is null (groupdescriptors are removed when datacontext is null)

If I add an item to the source a group is formed and the item is placed there. So far so good, but I want the code to expand the newly formed group and select/highlight the newly added item. What's the best approach? I have tried the gridview's grouped event, but that does not fire. I have tried the itemcontainergenerator, but the added grouping row does not seem to fire anything?

2 Answers, 1 is accepted

Sort by
0
Trude
Top achievements
Rank 2
answered on 28 Nov 2012, 01:34 PM
Seems like I can use ScrollIntoView or ScrollIntoViewAsync, but I can't get the grid to focus on the added item by setting SelectedItem/CurrentItem?
0
Trude
Top achievements
Rank 2
answered on 29 Nov 2012, 08:52 AM

I solved this problem by using this call - it expands the group, scrolls into view and selects the item - perfect!

GridView1.ScrollIntoViewAsync(item, _
    Sub(f)
        GridView1.Focus()
        GridView1.SelectedItem = item
        GridView1.CurrentItem = item
    End Sub)
Tags
GridView
Asked by
Trude
Top achievements
Rank 2
Answers by
Trude
Top achievements
Rank 2
Share this question
or