<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c1c="clr-namespace:C1.WPF.C1Chart">
    <!-- Legend style -->
    <Style TargetType="{x:Type c1c:C1ChartLegend}" x:Key="Legend">
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="Margin" Value="5"/>
        <Setter Property="Background" 
            Value="{DynamicResource C1Chart_LegendBackground_Brush}" />
        <Setter Property="BorderBrush" 
            Value="{DynamicResource C1Chart_LegendBorder_Brush}" />
        <Setter Property="BorderThickness" 
            Value="{DynamicResource C1Chart_LegendBorder_Thickness}" />
        <Setter Property="Foreground" 
            Value="{DynamicResource C1Chart_LegendForeground_Brush}" />
        <Setter Property ="ItemTemplate">
            <Setter.Value>
                <DataTemplate DataType="{x:Type c1c:LegendItem}">
                    <StackPanel Orientation="Horizontal">
                        <Canvas Width="24" Height="24">
                            <ContentControl Canvas.Top="2" Content="{Binding Path=Line}" Width="24" Height="20"/>
                            <ContentControl Canvas.Left="5" Canvas.Top="5" Content="{Binding Path=Symbol}" Width="14" Height="14"/>
                        </Canvas>
                        <TextBlock Margin="2"
                       Text="{Binding Path=Label}" 
                       VerticalAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type c1c:C1ChartLegend}">
                    <Border Name="bdr"
            BorderBrush="{DynamicResource C1Chart_LegendBorder_Brush}" 
            BorderThickness="{TemplateBinding BorderThickness}"
            Background="{DynamicResource C1Chart_LegendBackground_Brush}"
            CornerRadius="{DynamicResource C1Chart_Legend_CornerRadius}"
            Margin="{TemplateBinding Padding}" >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <ContentControl Foreground="{TemplateBinding Foreground}" x:Name="title" 
                            HorizontalContentAlignment="Center" Content="{TemplateBinding Title}" />
                            <ScrollViewer Name="sv" Grid.Row="1" VerticalScrollBarVisibility="Auto">
                                <WrapPanel Orientation="{TemplateBinding Orientation}"
                        IsItemsHost="true" />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsSource" Value="{Binding Path=LegendItems}" />
    </Style>
</ResourceDictionary>