自定义形状 [英] Custom Shape

查看:94
本文介绍了自定义形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定这是否有可能...

我想制作一个自定义形状(也许可以混合使用).该形状有些复杂,因为它可能具有曲线,笔直的边缘和贯穿其中的孔.

然后,我要对形状进行显示,并具有可绑定到我的视图模型的fill属性.

例如,我目前使用的是椭圆形,并且其中包含

Not sure if this is even possible...

I would like to make a custom shape (maybe it can be done in blend). The shape is somewhat complex in that it could have curves, straight edges, and holes through out it.

What I want to do with the shape is then display it and have a fill property that is bindable to my view models.

For example I currently use an Ellipse and I have with in it

<ellipse.fill>
  <solidcolorbrush color="{Binding Path=ItemColor}" />
</ellipse.fill>



我宁愿将自定义形状/对象填充在没有孔的地方.

可以做到这一点,如果有的话,一些代码会有所帮助.

这需要在XAML中完成.

我想出了一种绘制复杂形状的方法.将点值放在多边形"中花了一段时间.我不知道如何调整它的大小.

为了进一步说明,该项目驻留在DataTemplate中,并一遍又一遍地重绘.我需要该形状占用适当数量的给定空间,因此多边形中的点"必须成比例.这可能吗?

谢谢,



I would rather have my custom shape/object that is filled where there are not holes.

Can this be done and if so a little code would help.

This needs to be done in XAML.

I have figured a way to draw the complex shape. Took a while by putting point values in Polygon. What I can''t figure out is how to have it resize appropriately.

To further explain the item resides in a DataTemplate and is redrawn over and over. I need the shape to take up the appropriate amount of given space so the "Points" in the polygon must be proportional. Is this possible?

Thank you,

推荐答案

所有这些功能都存在,请查看下面的链接.您需要以Fill开头的方法,例如FillPolygon和FillClosedCurve.

http://msdn.microsoft.com/en-us/library/4cy2c290.asp [ ^ ]

一个C#示例:
http://www.java2s.com/Code/CSharp/2D-Graphics/DrawPolygon.htm [^ ]

祝你好运!
All these functions exist, have a look at the link below. You need the methods starting with Fill like FillPolygon and FillClosedCurve.

http://msdn.microsoft.com/en-us/library/4cy2c290.asp[^]

An c# example:
http://www.java2s.com/Code/CSharp/2D-Graphics/DrawPolygon.htm[^]

Good luck!


这篇关于自定义形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆