c# - Why are there the gaps between shapes in wpf -


i try draw rectangles side side,but there gap perhaps 1 pixel between the rectangles. better after set rectangle's snapstodevicepixels =true or uselayoutrounding = true,but after resize window,the gaps still occur.

here code drawing rectangle.

    protected override void onrendersizechanged(sizechangedinfo sizeinfo)     {         base.onrendersizechanged(sizeinfo);         drawrectangle();     }      private void drawrectangle()     {         var width = this.grid1.actualwidth;         var height = this.grid1.actualheight;         var step = width / 15;         this.grid1.children.clear();         (int = 0; < 15; i++)         {             rectangle rectangle = new rectangle();             rectangle.width = step;             rectangle.height = height;             rectangle.horizontalalignment = system.windows.horizontalalignment.left;             rectangle.margin = new thickness(i * step, 0, 0, 0);             rectangle.fill = new solidcolorbrush(colors.blue);             rectangle.snapstodevicepixels = true;             //rectangle.uselayoutrounding = true;             this.grid1.children.add(rectangle);         }     } 

how setting rectangle.stroke property same colour?:

rectangle.stroke = new solidcolorbrush(colors.blue); rectangle.strokethickness = 1.0; 

update >>>

after have specified actually want multiple rows of rectangle objects, can recommend use wrappanel instead of grid control. can achieve no joining lines using following code in loop:

rectangle rectangle = new rectangle(); rectangle.width = step; rectangle.height = height; rectangle.fill = new solidcolorbrush(colors.blue); rectangle.snapstodevicepixels = true; this.grid1.children.add(rectangle); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -