WPF dashed line — fix dashes during resize

微笑、不失礼 提交于 2019-12-11 00:53:28

问题


How can I avoid line dash resize during the window resize? Consider the following image: http://leprastuff.ru/data/img/20130315/b83eea4a7a3f07ca53a0e118ddbb9230.Gif

<Rectangle SnapsToDevicePixels="True"
           Stroke="DarkGray"
           StrokeDashArray="10 10"
           StrokeThickness="1" />

Thanks, Tony.


回答1:


Set the Height of the Rectangle to something greater than one.

Currently you're drawing the upper and lower border on top of each other. As the dashed stroke draws the Rectangle's border clockwise, starting at the top-left corner, you get the observed behaviour.

If you intended to draw a Rectangle with a height of one, you might better draw a Line instead.



来源:https://stackoverflow.com/questions/15439153/wpf-dashed-line-fix-dashes-during-resize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!