title: Centering or manually positioning dynamic controls on a WPF Canvas
body: <p>I'm trying to create Labels that are centered around different columns on a Canvas. This code looks plausible:</p>
  
  <pre><code>string[] titles = { "Acorn", "Banana", "Chrysanthemum" };
  double col = 20.0;
  foreach (string s in titles) 
  {
      var lbl = new Label() { Content = s };
      lbl.SetValue(Canvas.LeftProperty, col - (lbl.Width / 2.0));
      myCanvas.Children.Add(lbl);
      col += 150.0;
  }
  </code></pre>
  
  <p>But it does not work because the <code>lbl.Width</code> (and <code>lbl.ActualWidth</code>) aren't calculated until rendering, which is long after the Labels are being created.</p>
  
  <p>Is there a way to get the accurate <code>Label.Width</code> prior to a layout operation? On a <code>Canvas</code> there isn't all the control layout and flow you get with Grids or StackPanels.</p>