Reputation: 219
I am interested in using the ExpanderView control with the following behavior:
Seems like this would be a common scenrario, to lazy load the expandable items.
So I have implemented simple code in the Expanded event to load items if they are not already loaded:
if (!expanded)
{
for (var x = 1; x <= 10; x++)
{
((ExpanderView)sender).Items.Add(new TextBlock() { Text = "Added this on expanded " + x.ToString() });
}
expanded = true;
}
The problem with this is that the items are not rendered properly the first time (anything below the control is not "pushed down" to allow the space for the items), presumably because the control does not know the item content in advance. On subsequent expansion, the items are displayed properly.
Anyone know how I can achieve this lazy loading with the ExpanderView?
Upvotes: 0
Views: 473
Reputation: 8363
Try doing a UpdateLayout() on your expanderview after the items have been added. If you are doing the expansion in the Expanded listener you can just do the following.
private void expander_Expanded(object sender, System.Windows.RoutedEventArgs e)
{
// add item here
((ExpanderView) sender).UpdateLayout()
}
Upvotes: 3