Hi,
In my code, I create a XamGrid control dynamically and assign a list of objects to its ItemsSource property. However, when I try to get some info of the rows in XamGrid control, I get 0 rows. I need to access information of the rows right after assigning a value to the ItemsSource. I also tried to use the UpdateLayout function of the XamGrid control, but it didn't create the rows right away, either.
Is there any way to force the XamGrid control to create rows immediately after setting its ItemsSource property?
Thank you.
Frank
Until the XamGrid goes through the Loaded phase your data will not be bound. So your best be in this case would be to attach the Loaded handler to your grid and exectute your code in that delegate.
The Loaded will be raised by the framework, so when you add your grid to the visual tree it will be raised.
grid.Loaded += new RoutedEventHandler(grid_Loaded);
void grid_Loaded(object sender, RoutedEventArgs e)
{
int x = ((XamGrid) sender).Rows.Count;
Debug.WriteLine(x);
}