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:

overalapping

the rectangles here overlapping.

the thing have achieve is:

wanted result

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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -