title: DrawingContext.DrawGeometry draws adjacent geometries with gap
body: <p>Using DrawingContext.DrawingGeometry I'm drawing two triangles with common edge. I want this triangles to be filled, but not stroked with pen, because pen has thickness, and resulting triangles would be half thickness bigger than expected. Using code attached below I'm getting strange result (see picture) - there is a small gap between triangles. What am I doing wrong? Is there some better way, than drawing extra line on common edge?</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="LearnDrawing.Window1"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:local="clr-namespace:LearnDrawing" xmlns:wpfApplication1="clr-namespace:WpfApplication1"
          Title="Window1"
          Height="500"
          Width="500"&gt;
      &lt;Grid&gt;
          &lt;wpfApplication1:DrawIt Width="400" Height="400" /&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>using System.Windows;
  using System.Windows.Media;
  
  namespace WpfApplication1
  {
     class DrawIt : FrameworkElement
     {
        VisualCollection visuals;
  
        public DrawIt()
        {
           visuals = new VisualCollection(this);
  
           this.Loaded += new RoutedEventHandler(DrawIt_Loaded);
        }
  
        void DrawIt_Loaded(object sender, RoutedEventArgs e)
        {         
           var visual = new DrawingVisual();
           using (DrawingContext dc = visual.RenderOpen())
           {               
              var t1 = CreateTriangleGeometry(new Point(0, 0), new Point(200, 0), new Point(0, 200));
              var t2 = CreateTriangleGeometry(new Point(200, 0), new Point(200, 200), new Point(0, 200));
              dc.DrawGeometry(Brushes.Black, null, t1);             
              dc.DrawGeometry(Brushes.Black, null, t2);
           }
           visuals.Add(visual);
        }
  
        static PathGeometry CreateTriangleGeometry(Point aPt1, Point aPt2, Point aPt3)
        {
           var figure = new PathFigure();
           figure.StartPoint = aPt1;
           figure.Segments.Add(new PolyLineSegment(new []{aPt2, aPt3}, true));
  
           var pg = new PathGeometry();
           pg.Figures.Add(figure);
           figure.IsClosed = true;
           figure.IsFilled = true;
  
           return pg;
        }
  
        protected override Visual GetVisualChild(int index)
        {
           return visuals[index];
        }
  
        protected override int VisualChildrenCount
        {
           get
           {
              return visuals.Count;
           }
        }
     }
  }
  </code></pre>
  
  <p>Result:</p>
  
  <p><img src="https://i.stack.imgur.com/THFjX.png" alt="Result screenshot"></p>