Bind Pie Chart Slice color to data

Apr 8, 2010 at 5:15 PM

I'm trying to bind the color of a slice to the data I pass to the chart. I'm able to do it with a datagrid using DataTrigger but it's seems like it's not possible with a piechart.

I'm I missing something ? Also, I'm kind new to WPF so, if you have a solution, example would be really appreciated.

Thanks !

Apr 8, 2010 at 6:09 PM

Find a way to do it !!

Since my object contains the name of the color , all I have to do is createa Palette, as you normally do to define the colors you want, and define only one ressouce that is bind to the object. Hope that's cleat for everyone. BTW I set this directly in the XAML of the "Window".

<charting:Chart.Palette>
                <datavis:ResourceDictionaryCollection>
                    <ResourceDictionary>
                        <Style x:Key="DataPointStyle" TargetType="Control">
                            <Setter Property="Background" Value="{Binding Path=ColorName}"/>
                        </Style>
                    </ResourceDictionary>
                </datavis:ResourceDictionaryCollection>
            </charting:Chart.Palette>

Aug 26, 2010 at 11:04 AM

+1 Nice.. worked right out of the box.