If you only want to change the color of the Pie slices the better approach would be to use a Palette
. But if you want to change another style property, for example the Stroke
, you should use the SliceStyles
collection. As you have noticed this collection is read-only and you cannot assign it directly.
However you could workaround this behavior and achieve your requirement by using an attached property where you could add the styles to the current SliceStyles
collection. Here is a sample in code:
ICollection GetSliceStyles(DependencyObject obj)
DependencyProperty SliceStylesProperty =
AddSliceStyles(DependencyObject d, DependencyPropertyChangedEventArgs e)
PieSeries pieSeries = (PieSeries)d;
ICollection styles = (ICollection)e.NewValue;
I attached a project demonstrating how to change the colors with predefined palette, custom palette and an attached property.
Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).