2010-09-23 60 views
1

我想在我的WPF图表中设计风格的传奇项目。我有以下LegendStyle,但这不会改变任何东西。我究竟做错了什么?WPF图例传奇项目风格

谢谢!

<Style x:Key="LegendStyle1" TargetType="{x:Type datavis:Legend}"> 
    <Setter Property="ItemContainerStyle"> 
     <Setter.Value> 
      <Style TargetType="charting:LegendItem"> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="charting:LegendItem"> 
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> 
           <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> 
            <Rectangle Width="40" Height="40" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" VerticalAlignment="Center" /> 
            <datavis:Title Content="{TemplateBinding Content}" VerticalAlignment="Center"/> 
           </StackPanel> 
          </Border> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
     </Setter.Value> 
    </Setter> 
</Style> 
+0

可能有人需要这个未来... HTTP://stackoverflow.com/questions/27417437/assigning-color-to-the-rectangle-近传奇项功能于WPF的工具包,图表线/ 27419445#27419445 – 2014-12-25 17:10:09

回答

0

您是否解决了这个问题?我想这也许TargetType的= “图表:传奇”>

<Style x:Key="LegendStyle1" TargetType="charting:Legend"> 
    <Setter Property="ItemContainerStyle"> 
     <Setter.Value> 
      <Style TargetType="charting:LegendItem"> 
       <Setter Property="Template"> 
        <Setter.Value> 
         <ControlTemplate TargetType="charting:LegendItem"> 
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> 
           <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> 
            <Rectangle Width="40" Height="40" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" VerticalAlignment="Center" /> 
            <datavis:Title Content="{TemplateBinding Content}" VerticalAlignment="Center"/> 
           </StackPanel> 
          </Border> 
         </ControlTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
     </Setter.Value> 
    </Setter> 
</Style>