开发者

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 b开发者_开发百科eing 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();
            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜