Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redrawing silverlight accordion item not working

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?

like image 268
Josh Avatar asked Oct 04 '10 19:10

Josh


1 Answers

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();
            }
like image 57
MaxWave Avatar answered Oct 14 '22 05:10

MaxWave