title: WPF - Center control (label) within Canvas
body: <p>Greetings</p>
  
  <p>I'm trying to fix the positioning of controls in my WPF Application. In my application I have several Labels which each are in a different Canvas. I'm trying to center the label within the canvas. The code I currently have for one Label is the following:</p>
  
  <pre><code>&lt;Canvas Height="42" HorizontalAlignment="Left" Margin="0,1,0,0" Name="canvasPlayer1" VerticalAlignment="Top" Width="172" &gt;
      &lt;Label Content="" Foreground="White" FontSize="15" FontFamily="Eurostile LT ExtendedTwo" Height="Auto" HorizontalAlignment="Center" Margin="0,5,0,0" Name="labelPlayer1Name" VerticalAlignment="Center" Width="Auto" /&gt;
  &lt;/Canvas&gt;
  </code></pre>
  
  <p>Now for starters the problem with this is that it does not center the text at all, it stays at the original position. What I'm trying to achieve is to center the content of the label in that canvas BUT it cannot exceed the width of the canvas.</p>
  
  <p>Helpful suggestions are welcomed! If you have any comments regarding my thinking pattern to solve this issue please do notify me as well!</p>
  
  <p>Thank you in advance</p>