title: WPF Shape bounding rectangle is always empty
body: <p>I have the following code in my WPF application:</p>
  
  <pre><code>public MainWindow()
      {
          InitializeComponent();
          p1 = new Point(50, 50);
          p2 = new Point(355, 50);
          p3 = new Point(50, 355);
          p4 = new Point(355, 355);
  
          Loaded += (x, y) =&gt; Draw();
          //ContentRendered += (x, y) =&gt; Draw();
      }
  </code></pre>
  
  <p>I create a Polygon shape and try to get its bounding rectangle <em>several ways</em>:</p>
  
  <pre><code> private void Draw()
      {
          Polygon polygon = new Polygon();
          polygon.Stroke = System.Windows.Media.Brushes.White;
          polygon.Points.Add(p1);
          polygon.Points.Add(p2);
          polygon.Points.Add(p3);
          polygon.Points.Add(p4);
          canvas.Children.Add(polygon);
          boundingRect = polygon.TransformToVisual(canvas).TransformBounds(new Rect(polygon.RenderSize));
          boundingRect = polygon.TransformToVisual(polygon).TransformBounds(System.Windows.Controls.Primitives.LayoutInformation.GetLayoutSlot(polygon));
          boundingRect = polygon.RenderTransform.TransformBounds(new Rect(polygon.RenderSize));
          boundingRect = GetRectOfObject(polygon);
          boundingRect = polygon.RenderedGeometry.Bounds;
      }
  
   private Rect GetRectOfObject(FrameworkElement _element)
      {
          Rect rectangleBounds = new Rect();
          rectangleBounds = _element.RenderTransform.TransformBounds(new Rect(0, 0, _element.ActualWidth, _element.ActualHeight));
          return rectangleBounds;
      }
  </code></pre>
  
  <p><strong>However, I always get {0;0;0;0}.</strong></p>
  
  <p>On debug, I can see the points but its size is rendered 0:</p>
  
  <p><a href="https://i.stack.imgur.com/FDia2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FDia2.png" alt="enter image description here"></a></p>
  
  <p>How should I calculate the correct way?</p>