开发者

Accordion Control in WPF

开发者 https://www.devze.com 2023-04-05 10:38 出处:网络
I am looking at this example for Accordion Control in the WPF Toolkit: http://www.dotnetspark.com/kb/1931-accordion-wpf-toolkit-tuto开发者_JAVA技巧rial.aspx

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

http://www.dotnetspark.com/kb/1931-accordion-wpf-toolkit-tuto开发者_JAVA技巧rial.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.


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)


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).

0

精彩评论

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