title: LabeledPieChart: Style overrides DataTemplate
body: <p>I have customized the template of LabeledPieChart (source: <a href="http://bea.stollnitz.com/blog/?p=438" rel="nofollow">Bea</a>) in a Style. Then I created a DataTemplate for the Slices of the LabeledPieChart. Both the style and the DataTemplate works great if they are alone. If they are together the Style overrides the DataTemplate that he has no effect. Is it possible to combine these two?
  Here is my Code (The Style and the DataTemplate are in Window.Resources):</p>
  
  <p><strong>Style:</strong></p>
  
  <pre><code>&lt;Style TargetType="customControls:LabeledPieChart" &gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="customControls:LabeledPieChart"&gt;
                      &lt;Grid&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="15*" /&gt;
                              &lt;ColumnDefinition Width="9*" /&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Grid Grid.Column="0"&gt;
                              &lt;Grid.RowDefinitions&gt;
                                  &lt;RowDefinition Height="Auto" /&gt;
                                  &lt;RowDefinition Height="*" /&gt;
                              &lt;/Grid.RowDefinitions&gt;
                              &lt;dataVis:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}" Margin="0,5,0,3"/&gt;
                              &lt;Grid Grid.Row="1" Margin="5"&gt;
                                  &lt;Grid.ColumnDefinitions&gt;
                                      &lt;ColumnDefinition Width="*" /&gt;
                                      &lt;ColumnDefinition Width="Auto" /&gt;
                                  &lt;/Grid.ColumnDefinitions&gt;
                                  &lt;chartPrmtvs:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}"&gt;
                                      &lt;Grid Canvas.ZIndex="-1" Background="Transparent" /&gt;
                                      &lt;Border Canvas.ZIndex="10" BorderBrush="#FF919191" BorderThickness="0" /&gt;
                                  &lt;/chartPrmtvs:EdgePanel&gt;
                              &lt;/Grid&gt;
                          &lt;/Grid&gt;
                          &lt;dataVis:Legend x:Name="Legend" Style="{TemplateBinding LegendStyle}" Title="{TemplateBinding LegendTitle}"
                                                  BorderThickness="0" Background="Transparent" FontSize="15" Grid.Column="1"/&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p><strong>DataTemplate:</strong></p>
  
  <pre><code>&lt;DataTemplate DataType="{x:Type local:City}" &gt;
          &lt;Border BorderThickness="1" BorderBrush="Gray"&gt;
              &lt;StackPanel Background="White" Orientation="Horizontal"&gt;
                  &lt;TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type customControls:PieChartLabel}}, Path=FormattedRatio}" VerticalAlignment="Center" Margin="5,0,5,0" /&gt;
                  &lt;TextBlock Text="- " /&gt;
                  &lt;TextBlock Text="{Binding Path=Population}" Margin="5,0,5,0" /&gt;
                  &lt;TextBlock Text="- " /&gt;
                  &lt;TextBlock Text="{Binding Name}" Margin="0,0,5,0"/&gt;
              &lt;/StackPanel&gt;
          &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  </code></pre>
  
  <p><strong>LabeldPieChart:</strong></p>
  
  <pre><code>&lt;Grid&gt;
      &lt;customControls:LabeledPieChart 
          x:Name="labeledPieChart"
          Title="Population of Puget Sound Cities"
          Height="500" Width="700"
          Grid.Row="3"
          BorderBrush="Gray"
          &gt;
          &lt;customControls:LabeledPieChart.Series&gt;
              &lt;customControls:LabeledPieSeries 
                  x:Name="labeledPieSeries"
                  ItemsSource="{Binding}" 
                  IndependentValuePath="Name" 
                  DependentValuePath="Population" 
                  IsSelectionEnabled="True" 
                  LabelDisplayMode="Auto"
                  /&gt;
          &lt;/customControls:LabeledPieChart.Series&gt;
      &lt;/customControls:LabeledPieChart&gt;
  &lt;/Grid&gt;
  </code></pre>