.net 是否有 WPF 控件可用于展开/折叠面板(动画)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/485232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 11:06:17  来源:igfitidea点击:

Is there a WPF control I can use to expand/collapse panels (animated)

.netwpfuser-interfaceaccordion

提问by Mark Carpenter

I have a window that has a lot of content. I'd like to be able to separate the content using panels, and have a separator that the user can click on the toggle between each panel (with an animation that moves the separator from left to right, showing one section and hiding the other). Think of the Microsoft Office (2007) navigation pane. Is there an easy way to accomplish this?

我有一个窗口,里面有很多内容。我希望能够使用面板分隔内容,并有一个分隔符,用户可以单击每个面板之间的切换(带有从左到右移动分隔符的动画,显示一个部分并隐藏另一个部分) . 想想 Microsoft Office (2007)导航窗格。有没有简单的方法来实现这一点?

Thanks!

谢谢!

采纳答案by Nir

I think what you are looking for is an "Accordion" control, here is a post abotu how to build one from a stack of Expander controls:

我想你正在寻找的是一个“手风琴”控件,这是一篇关于如何从一堆扩展器控件中构建一个的帖子:

http://www.rooijakkers.net/Blog/post/2007/11/WPF-implementation-of-a-basic-Accordion-control.aspx

http://www.rooijakkers.net/Blog/post/2007/11/WPF-implementation-of-a-basic-Accordion-control.aspx

And for the animation take a look at the "Reveal" control from Kevin's bag-o-tricks at http://j832.com/bagotricks/

对于动画,请查看http://j832.com/bagotricks/ 上Kevin 的 bag-o-tricks 中的“Reveal”控件

I think there's even an animated Expander control template based on the Reveal control in the sample project.

我认为在示例项目中甚至还有一个基于 Reveal 控件的动画扩展器控件模板。

回答by Anthony Brien

I also need this for my WPF application, and the best I've found is the fully featured Accordion control in the Silverlight Toolkit:

我的 WPF 应用程序也需要这个,我发现最好的是 Silverlight Toolkit 中功能齐全的 Accordion 控件:

alt text http://www.sitechno.com/Blog/ct.ashx?id=a7c3c2d9-9446-4236-bc6e-c436427002ff&url=http%3a%2f%2fwww.sitechno.com%2fBlog%2fcontent%2fbinary%2fWindowsLiveWriter%2fAccordionpart1_102BB%2fimage_2.png

替代文字 http://www.sitechno.com/Blog/ct.ashx?id=a7c3c2d9-9446-4236-bc6e-c436427002ff&url=http%3a%2f%2fwww.sitechno.com%2fBlog%2fcontent%2fbinary%2fWindowsLive 2fAccordionpart1_102BB%2fimage_2.png

The source code is available here, and a live demo here. It's probably easy to port to WPF. There's a 5 part blog entryby Ruurd Boeke discussing it in details. In part 4, he discusses how to restyle the accordion using templates to get this great accordion look:

源代码可在此处获得,现场演示可在此处获得。移植到 WPF 可能很容易。Ruurd Boeke有一个由5 部分组成的博客条目,详细讨论了它。在第 4 部分中,他讨论了如何使用模板重新设计手风琴的样式以获得这种出色的手风琴外观:

alt text
(source: sitechno.com)

替代文字
(来源:sitechno.com

alt text
(source: sitechno.com)

替代文字
(来源:sitechno.com

回答by Bryan Anderson

I use Expander.

我使用扩展器。

<Expander Header="Items" IsExpanded="False">
    ...
</Expander>