How to specify color palette in XAML

1 posts, 0 answers
  1. Darek
    Darek avatar
    16 posts
    Member since:
    Mar 2009

    Posted 16 Nov 2009 Link to this post

    Requirements

    RadControls
    2009 Q3


    .NET version
    3.5


    Visual Studio 2008


    programming language
    C#


    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    Occasionally, you might find yourself in need of customizing chart colors, without having time to develop an entirely new theme. In such case you may specify Style Palettes globally, if you use a shared ResourceDictionary, or locally at the UserControl Resources level.
    Here is a sample how to do it for bar and line series. This approach works even for grouped charts, where the grouping is defined from XAML instead of code-behind.

        <Charting:StylesPalette x:Key="BarStyle"
            <Style TargetType="Shape"
                <Setter Property="Fill" Value="#FF628ED5" /> 
                <Setter Property="Stroke" Value="Black" /> 
                <Setter Property="StrokeThickness" Value="1" /> 
            </Style> 
            <Style TargetType="Shape"
                <Setter Property="Fill" Value="#FF92B1E2" /> 
                <Setter Property="Stroke" Value="Black" /> 
                <Setter Property="StrokeThickness" Value="1" /> 
            </Style> 
        </Charting:StylesPalette> 
     
        <Charting:StylesPalette x:Key="LineStyle"
            <Style TargetType="Charting:SelfDrawingSeries"
                <Setter Property="BorderLineStyle"
                    <Setter.Value> 
                        <Style TargetType="Shape" > 
                            <Setter Property="StrokeThickness" Value="2" /> 
                            <Setter Property="Fill" Value="Yellow" /> 
                            <Setter Property="Stroke" Value="Yellow" /> 
                        </Style> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
            <Style TargetType="Charting:SelfDrawingSeries"
                <Setter Property="BorderLineStyle"
                    <Setter.Value> 
                        <Style TargetType="Shape" > 
                            <Setter Property="StrokeThickness" Value="2" /> 
                            <Setter Property="Fill" Value="Green" /> 
                            <Setter Property="Stroke" Value="Green" /> 
                        </Style> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
        </Charting:StylesPalette> 

    You may specify up to 10 colors for each palette.

Back to Top