Is there a way for AccordionItem to adjust to the new content size (without Select/Unselect)

Mar 4, 2010 at 12:09 AM
Edited Mar 4, 2010 at 12:10 AM

If you have a markup like this:

    <StackPanel>
        <Controls:Accordion>
            <Controls:AccordionItem Header="List">
                <ListBox x:Name="lb">
                    <ListBoxItem>abc</ListBoxItem>
                    <ListBoxItem>abc</ListBoxItem>
                    <ListBoxItem>abc</ListBoxItem>                    
                </ListBox>
            </Controls:AccordionItem>
            <Controls:AccordionItem Header="Text">
                <TextBlock>simple text</TextBlock>
            </Controls:AccordionItem>
        </Controls:Accordion>
        <Button Content="Test" Click="Button_Click"/>
    </StackPanel>
and on click add an item to the listbox, the listbox gets a scrollbar. 
But if you select the second item and then select the first one, 
the item content gets resized to fit all listbox items. 
My question is how to force this re-size programmatically, without collapsing and expanding the items?

 

Coordinator
Mar 11, 2010 at 12:17 AM

Hi-

I took a look at this, and unfortunately the Accordion control has this behavior defined as the default, so the short answer is that without changing assumptions in different parts of the code, or having a number of "hacks" in place to simulate the expand/collapse, none of which would be very subtle, the control won't re-size automatically. I'll take it as a work item, should we ever be able to make changes to the existing behavior.

Thanks!

Patrick

Apr 1, 2010 at 12:01 PM
Patrick, I have the same issue when I use accodion in accordtion in accordion(3 levels). When I expand the level 3 accordion, level 2 accordion doesn't automatically expand, Any news on the issue?
Sep 20, 2010 at 2:52 PM
Edited Sep 20, 2010 at 2:54 PM

Okey, no one answered, so I fixed the issue myself. 

The fix worked in my case, and should work in other cases as well.

Here's the patch for this: http://wpf.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=151825

Hope this helps someone.

PS: please apply the patch to the Layout\Layout\Accordion\System\Windows\Controls\Accordion.cs file

Dec 13, 2010 at 4:54 PM

Thanks.  This is exactly what I needed!