title: Centering TextBlock text inside border element
body: <p>I am playing around with silverlight - specifically Silverlight for windows phone. I would like to have a textblock inside a border element. I want the textblock to fill up the entire border element. I would also like the text inside the textblock to the centered within the textblock - both vertical and horizontal.</p>
  
  <p>The problem that I am encountering is that if I set the horizontal and vertical alignment of the textblock to center, then the textblock resizes to the size of the text, hence the textblock does not fill up all the available room inside the border. If I set the horizontal and vertical alignment properties of textblock to stretch, I get the textblock to expand to fill up the border, but the textblock text is not centered anymore. I think I can use padding to center the text, but this does not give a precise result as the length of the text can vary.</p>
  
  <p>The reason why I would like to have the textblock within a border in the first place is because Silverlight for Windows Phone does not provide a background property for textblock. I use the border to provide a background color.</p>
  
  <p>In short, is there any way to center the text in a textblock, when the textblock is inside a border element and the textblock must stretch to fill the border.</p>
  
  <p>Below is the code that I have so far.</p>
  
  <pre><code>&lt;Border BorderBrush="Red" BorderThickness="2" Grid.Row="0" Grid.Column="0"&gt;
      &lt;TextBlock Name="textBlockA1" Text="Center Me!" HorizontalAlignment="Stretch"            
          VerticalAlignment="Stretch"/&gt;
  &lt;/Border&gt;
  </code></pre>