I have a datagrid in an accordion that I programmatically add items to. The items don't have a problem being added, but the accordion item doesn't refresh to a size that can view all the contents of the datagrid. If I drag the datagrids sides to resize it, the accordion item resizes correctly. I can't seem to do this automatically through code. I have tried InvalidateArrage and InvalidateMeasure on the grid or the accordion item and I've also tried changing the widths or heights of the controls, but nothing seems to work through code. I've even tried the Invalidate methods on the LayoutRoot. Is there anything I can do code wise to make the accordion item refresh to the proper size?
I have the same issue, but with ListBox in AccordionItem. I solve this - put your DataGrid in Grid control
<toolkit:Accordion.ContentTemplate>
<DataTemplate>
<Grid>
<DataGrid.../>
</Grid>
</DataTemplate>
</toolkit:Accordion.ContentTemplate>
And you need to call UpdateLayout() method when you ItemsSource is changed (item added)
private void ItemsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
yourAccordion.UpdateLayout();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With