Crystal
Crystal

Reputation: 29458

Accordion Control in WPF

I am looking at this example for Accordion Control in the WPF Toolkit:

http://www.dotnetspark.com/kb/1931-accordion-wpf-toolkit-tutorial.aspx

I put my two items in there that I used to resize between using a GridSplitter (basically 1 row, 2 cols).

   A: stuff here on one side of screen (gridsplitter) B: stuff here on other side of screen 

When I use that example and put each item as an AccordionItem, each item takes up the whole screen. So it's all A, and then if I hit the >, it's all B. Is there a way to do it so I can have my same setup, split screen, then you hit >, and it shrinks one side (A) and (B) will take up the whole screen, and then if you hit the other >, it shrinks side (B) and (A) takes up the whole screen. Like the little < and > in Outlook, to shrink the folder view on the LHS, and Calender View on the RHS. Thanks.

Upvotes: 0

Views: 15096

Answers (3)

Mr. Squirrel.Downy
Mr. Squirrel.Downy

Reputation: 1167

The pure XAML solution make TabControl be Accordion:
https://stackoverflow.com/a/78650383/6859121 (Answered by me)

The drawback is that it cannot adapt to the container size, but this can be solved by a few of code.

Upvotes: 0

JamesHoux
JamesHoux

Reputation: 3447

Here is a demo project that implements a complete animated accordion in 125 lines of pure XAML in WPF:

Accordion on WPF Pure XAML

It appears to work like a charm when I opened the Visual Studio solution and tested it. Someone really ought to create a GitHub repository for this. If it turns out to work in my own project, I'll probably throw it up on a git hub repository, and edit this post to link to it.

And of course there's also the link suggested in a comment above. I'm replacing it here for thoroughness:

StackOverflow Question: Accordion Control for NET 4 (from Expanders)

The approach described on that SO question implements Expanders which are basically accordions each having one only one single heading with content pane. Stacking multiple Expanders together is a way to create a full accordion.

Another SO question that discusses use of Expanders with Templates to create an accordion:

Accordion Widget in Wpf (from Expanders)

Upvotes: 2

tsells
tsells

Reputation: 2771

We had a similar issue. We ended up creating our own custom accordion control since it's not available in .Net 4.0. I would highly recommend looking into doing this. Rolling your own will allow you to have more control over this as well as determine how many content panels you want in it (two, three, etc).

Upvotes: 0

Related Questions