我想在silverlight中制作一个“dash dot dot”风格的画笔。我不能使用 Rectangle 因为我实际上想在 Path 元素(不是矩形图形)周围完成一个“虚线点”边框。有没有办法做到这一点?
谢谢,罗曼。
我想在silverlight中制作一个“dash dot dot”风格的画笔。我不能使用 Rectangle 因为我实际上想在 Path 元素(不是矩形图形)周围完成一个“虚线点”边框。有没有办法做到这一点?
谢谢,罗曼。
It sounds like you just need the StrokeDashArray property of the Path. For example,
StrokeDashArray="3 1 1 1 1 1"
will give a dash dot dot pattern.
Translated to english it says:
Dash of 3 units, gap of 1 unit, dash of 1 unit, gap of 1 unit, dash of 1 unit, gap of 1 unit.
I say units, because, per MSDN: "Each Double in the collection specifies the length of a dash or gap relative to the Thickness of the pen.".
A full path markup sample,
<Path Data="M120,141 C344,128 314,1 397,145 C480,289 619,392.00076 418,369.00067 C217,346.00061 131.99998,314.00018 134.99998,243.00008 C137.99998,171.99995 120,141 120,141 z" Fill="#FFF4F4F5" Margin="119.5,76.374,117.918,107.283" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" StrokeDashArray="3 1 1 1 1 1"/>
MSDN link: http://msdn.microsoft.com/en-us/library/system.windows.shapes.shape.strokedasharray.aspx