I am trying to make a pie chart custom control, and I will need to have an unknown number of pie slices. I am trying to accomplish this by creating a custom property, called maybe DrawingCode, and this code will be a string which can be converted and interpreted by a DrawingGroup. I was hoping for DrawingGroup.Children to be bound to TemplateBinding DrawingCode and use a converter, but I don't know how to convert a string into a list of GeometryDrawings. Any help is appreciated!
Here is the ResourceDictionary containing the generic for my PieChart control:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFTest">
<Style TargetType="{x:Type local:PieChart}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:PieChart}">
<Image>
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup Children="{TemplateBinding DrawingCode}" />
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>