title: XAML Data Template Style Border with TextBlock
body: <p>I'm not sure if this is possible, but I want to see if anyone knows. I want to write a style for a data template that is a Border with a TextBlock inside. Ideally, I would like to have the whole thing in one style. Right now I have the style for the Border and the TextBlock separately. </p>
  
  <p><strong>Here is my DataTemplate:</strong></p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type local:MyObject}"&gt;
      &lt;Border Style="{StaticResource BorderStyle}"&gt;
          &lt;TextBlock Style="{StaticResource TextBlockStyle}"/&gt;
      &lt;/Border&gt;
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p><strong>Style for the Border</strong></p>
  
  <pre><code>&lt;Style x:Key="BorderStyle" TargetType="Border"&gt;
      &lt;Setter Property="BorderBrush" Value="Black"/&gt;
      &lt;Setter Property="BorderThickness" Value="1"/&gt;
      &lt;Setter Property="CornerRadius" Value="90"/&gt;
      &lt;Setter Property="Width" Value="45"/&gt;
      &lt;Setter Property="Height" Value="45"/&gt;
      &lt;Setter Property="Background" Value="White"/&gt;
      &lt;Setter Property="Opacity" Value=".75"/&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p><strong>Style for the TextBlock</strong></p>
  
  <pre><code>&lt;Style x:Key="TextBlockStyle" TargetType="TextBlock"&gt;
      &lt;Setter Property="Text" Value="{Binding Name}"/&gt;
      &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
      &lt;Setter Property="HorizontalAlignment" Value="Center"/&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Code Complete gave me additional properties for the Border which I thought would work, but they didn't seem to work.</p>
  
  <pre><code>&lt;Style x:Key="BorderStyle" TargetType="Border"&gt;
      ...
      &lt;Setter Property="TextBlock.VerticalAlignment" Value="Center"/&gt;
      ...
  &lt;/Style&gt;
  </code></pre>