Hi,
I'm binding a XamWebGrid to some data and using a ColumnLayout.
I managed to get a button to expand all rows by iterating through them and calling IsExpanded=True. That works perfectly fine.
My issue is that I want the grid to start in the expanded state. I tried to find a decent "end of binding" event but couldn't find any. I hooked up on the Rows.CollectionChanged and the event gets fired OK.
However, when I iterate through the rows and set their expanded state to true, they are shown as expanded (arrow pointing downwards) but don't display the data.
If I click on them and collapse/expand them, then the data is displayed OK. I guess there's a timing issue or something and the expansion event isn't yet registered on the row when I expand it in code.
Is there any way of achieving the "start as expanded" behaviour?
PS: I only have one ColumnnLayout in the view
PPS: the collection to which I bound the grid sends the Reset event and not Add.
Cheers.
When are you iterating through the Rows collection? The earliest you would want to do that is during the Loaded event of the grid.
public MainPage()
{
InitializeComponent();
this.grid.Loaded += new RoutedEventHandler(grid_Loaded);
}
void grid_Loaded(object sender, RoutedEventArgs e)
List<Person> p = new List<Person>();
for (int i = 0; i < 10; i++)
int? x = i % 3 == 1 ? null : (int?)i;
Person b = new Person() { ID = x, Name = " Person " + i };
ObservableCollection<Person> Kids = new ObservableCollection<Person>();
Kids.Add(new Person() { Name = "kid of person "+i });
b.Kids = Kids;
p.Add(b);
grid.ItemsSource = p;
foreach (Row r in grid.Rows)
r.IsExpanded = true;
public class Person
public int? ID { get; set; }
public string Name { get; set; }
public ObservableCollection<Person> Kids
get;
set;