Silverlight 中 PathGeometry 的自定义填充属性
我一直在研究(并感到困惑)依赖属性 - 我不确定这是否是我需要的或者是否还有其他东西。
我正在寻找 Silverlight 中
子项的非常具体的内容,特别是
、
等。虽然
元素具有 .Fill
属性,但我想添加一个 。 Fill
属性为其任何几何图形,这意味着它的颜色与其父级不同。它可以是
或
颜色,或父颜色的百分比(例如比 深 20%) ?
例如,这是一个依赖属性吗 我如何开始?
(添加 WPF 作为标签,了解 WPF 的人可能会提供帮助)
I've been looking at (and getting confused by) Dependency Properties - I'm not sure if this is what I need or if there is something else.
I'm looking to something very specific with <Path.Data/>
children in Silverlight, in particular <PathGeometry/>
, <EllipseGeometry/>
, etc. While the <Path/>
element has a .Fill
property, I'd like to add a .Fill
property to any of it's Geometries, meaning it's a different color from it's parent. It could be a <SolidColorBrush/>
or <LinearGradientBrush/>
color, or a percentage of the parent color (like 20% darker than <Path.Fill/>
.
Is this possible? Is this a dependency property? How would <RectangleGeometry/>
, for example, know that I am trying to fill it with a color? How would I get started?
(adding WPF as a tag too as someone who knows WPF may be able to help)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
并非不可能,描边和填充画笔是
Path
形状的属性。如果您想使用自己独立的 Stroke 和 Fill 属性绘制矩形、椭圆形等形状,则需要使用
Rectangle
和Ellipse
它们是Shape
对象以他们自己的权利。Not its not possible, the stroke and fill brush are properties of the
Path
shape.If you want to draw Rectangle, Ellipse etc shapes with their own independent Stroke and Fill properties you need to use
Rectangle
andEllipse
which areShape
objects in their own right.