You can use PieSeries' SliceStyleSelector
property to instantiate a custom StyleSelector. The SelectStyle
method of your custom StyleSelector will be called when:
- An item from the PieSeries ItemsSource is removed
- An item is added to the PieSeries ItemsSource
- The value of an existing item in the ItemsSource is changed
Here's an example:
PieSliceStyleSelector : StyleSelector
item, DependencyObject container)
var dp = item
var series = container
var chart = series.ParentOfType<RadPieChart>();
var paletteEntries = chart.Palette.GlobalEntries;
var slice = series.ChildrenOfType<Path>()
.Where(p => p.DataContext == dp).First();
slice.Fill = paletteEntries[dp.Index % paletteEntries.Count].Fill;
//Attach to slice events...
//or return custom style
Please note that the Paths that represent the individual pie slices are recycled (when a datapoint is removed the visual element is not released, but is used when a new datapoint is added) and that's why the OnDetaching() method of the Behavior was not called.
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>