如何在 WPF 中创建径向菜单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16468555/
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-13 08:45:42  来源:igfitidea点击:

How to create Radial Menu in WPF

wpf

提问by Ravuthasamy

Can anybody give suggestion how to create Radial menu in WPF,if you give any sample it will be helpfull,

任何人都可以建议如何在 WPF 中创建径向菜单,如果您提供任何示例,它将有所帮助,

回答by Typhon

I highly suggest you to take a look at what I've done here

我强烈建议你看看我在这里做了什么

WPF RadialMenu

WPF 径向菜单

To sum up how it works

总结它是如何工作的

First, the radial menu itself :
I created a custom ContentControl RadialMenu, which can only have children of the type RadialMenuItem, then in the method ArrangeOverrideof the radial menu I give to each children its Index Position in the radial menu and the Total Count of children.

首先,径向菜单本身:
我创建了一个自定义 ContentControl RadialMenu,它只能有RadialMenuItem类型的子,然后在ArrangeOverride径向菜单的方法中,我给每个子项在径向菜单中的索引位置和子项的总计数.

Secondly, the items of the radial menu :
Each RadialMenuItemis a custom Button with a custom Template, knowing is Index Position inside the Total Count of children, the item is able to create a PieShape(with some trigonometry) for its template.

其次,径向菜单的项目:
每个RadialMenuItem都是一个带有自定义模板的自定义按钮,知道子项总数内的索引位置,该项目能够为其模板创建一个PieShape(带有一些三角函数)。

Finally, the central item of the radial menu:
The RadialMenuCentralItemis also a custom Button with a custom Template, but the Template is just an Elipse Shape, this item is placed in the radial menu, through the CentralItemProperty of the radial menu.

最后,径向菜单中心项目:
RadialMenuCentralItem还具有自定义模板的自定义按钮,但模板仅仅是一个Elipse形状,这个项目被放置在径向菜单,通过CentralItem径向菜单的属性。

Then with some Trigger, Animation, Bindingand DependencyProperty, you will be able to do that

然后使用一些TriggerAnimationBindingDependencyProperty,您将能够做到这一点

WPF RadialMenu

WPF 径向菜单