c# - Drawing Grid pattern on Canvas with straight lines instead of rectangles -
right draw grid brush:
<visualbrush x:key="gridbrush" tilemode="tile" viewport="0,0,60,60" viewportunits="absolute" viewbox="0,0,60,60" viewboxunits="absolute" > <visualbrush.visual> <rectangle stroke="darkgray" strokethickness="1" height="60" width="60" strokedasharray="5 3"/> </visualbrush.visual> </visualbrush>
and effect:
the rectangles here overlapping.
the thing have achieve is:
instead of visualbrush, better use drawingbrush:
<drawingbrush tilemode="tile" viewport="0,0,60,60" viewportunits="absolute" viewbox="0,0,60,60" viewboxunits="absolute"> <drawingbrush.drawing> <geometrydrawing geometry="m0,0 l60,0 m0,0 l0,60"> <geometrydrawing.pen> <pen brush="darkgray" thickness="1" dashcap="flat"> <pen.dashstyle> <dashstyle dashes="5,3"/> </pen.dashstyle> </pen> </geometrydrawing.pen> </geometrydrawing> </drawingbrush.drawing> </drawingbrush>
you may explicitly declare geometry group of 2 lines:
<drawingbrush tilemode="tile" viewport="0,0,60,60" viewportunits="absolute" viewbox="0,0,60,60" viewboxunits="absolute"> <drawingbrush.drawing> <geometrydrawing> <geometrydrawing.geometry> <geometrygroup> <linegeometry endpoint="0,60"/> <linegeometry endpoint="60,0"/> </geometrygroup> </geometrydrawing.geometry> <geometrydrawing.pen> <pen brush="darkgray" thickness="1" dashcap="flat"> <pen.dashstyle> <dashstyle dashes="5,3"/> </pen.dashstyle> </pen> </geometrydrawing.pen> </geometrydrawing> </drawingbrush.drawing> </drawingbrush>
Comments
Post a Comment