title: WPF Label DataTemplate
body: <p>I am trying to define a datatemplate for a label. Is this possible? Since I could not find anything helpful to move forward I defined a control template and tried to get things working. Unfortunately when I bind two items as follows I get the label displaying nothing, even though an object with the given parameters has been successfully bound to the label from the code behind. Please help!</p>
  
  <pre><code>&lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="Label"&gt;
                      &lt;Border&gt;
                          &lt;Grid&gt;
  
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                                  &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
  
                              &lt;TextBlock Background="Green" Text="{Binding TableName}" Grid.Column="0"&gt;&lt;/TextBlock&gt;
                              &lt;TextBlock Background="Red" Text="{Binding ColumnName}"  Grid.Column="1"&gt;&lt;/TextBlock&gt;
  
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
  </code></pre>
  
  <p>Edited: Full Xaml of the window.resources as requested</p>
  
  <pre><code>  &lt;Window.Resources&gt;
  
      &lt;Style x:Key="myLabelTemplate" TargetType="Label"&gt;
          &lt;!--&lt;Setter Property="Background" Value="DarkKhaki"&gt;&lt;/Setter&gt;
           &lt;Setter Property="Foreground" Value="White"&gt;&lt;/Setter&gt;--&gt;
  
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="Label"&gt;
                      &lt;Border&gt;
                          &lt;Grid&gt;
  
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                                  &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                              &lt;/Grid.ColumnDefinitions&gt;
  
                             &lt;!-- &lt;TextBlock Background="Green" Text="{Binding TableName}" Grid.Column="0"&gt;&lt;/TextBlock&gt;
                              &lt;TextBlock Background="Red" Text="{Binding ColumnName}"  Grid.Column="1"&gt;&lt;/TextBlock&gt;--&gt;
  
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
  
      &lt;/Style&gt;
  
  
      &lt;!-- &lt;ControlTemplate TargetType="Label" x:Key="tablelLabel"&gt;
          &lt;Grid&gt;
              &lt;Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="5" CornerRadius="5"&gt;
                  &lt;Border.Background&gt;
                      &lt;SolidColorBrush Color="#50000000"&gt;&lt;/SolidColorBrush&gt;
                  &lt;/Border.Background&gt;
              &lt;/Border&gt;
              &lt;Grid&gt;
                  &lt;Grid.Background&gt;
                      &lt;LinearGradientBrush StartPoint="0.5,0"  EndPoint="0.5,1"&gt;
                          &lt;GradientStop Color="Transparent" Offset="0" /&gt;
                          &lt;GradientStop Color="Black" Offset="1" /&gt;
                          &lt;GradientStop Color="Transparent" Offset="1" /&gt;
                      &lt;/LinearGradientBrush&gt;
                  &lt;/Grid.Background&gt;
              &lt;/Grid&gt;
          &lt;/Grid&gt;
  
      &lt;/ControlTemplate&gt; --&gt;
  
      &lt;ControlTemplate TargetType="Label" x:Key="generalLabel"&gt;
          &lt;Grid&gt;
              &lt;Border BorderBrush="#34B7AEAE" BorderThickness="3" CornerRadius="5"&gt;
              &lt;/Border&gt;
          &lt;/Grid&gt;
      &lt;/ControlTemplate&gt;
  
  &lt;/Window.Resources&gt;
  </code></pre>