views:

120

answers:

1

Hello,

I am trying to style the Legend Items in my WPF Chart. I have the following LegendStyle, but this doesn't change anything. What am I doing wrong?

Thanks!

<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>
A: 

Did you solve this? I think it maybe TargetType="charting:Legend">

<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> 
t.o.f.y