7 Answers, 1 is accepted
Could you elaborate a bit more on your requirement? What do you mean by databinding the colors for the Pie Slices? Do you mean that you want each of your Slice colored due to condition - for example if it's Value is > 100 - apply red color otherwise apply Blue color?
Greetings,
Evgenia
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
yes. but I will have the color hex value in the view model, so just bind it to the slice's background color.
Kevin
You can bind your custom color to the Pie's slice by it's style:
<
Style
x:Key
=
"PieStyle"
TargetType
=
"telerik:Pie"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:Pie"
>
<
Canvas
x:Name
=
"PART_MainContainer"
>
<
Ellipse
Clip
=
"{TemplateBinding FigurePath}"
Width
=
"{TemplateBinding ItemActualWidth}"
Height
=
"{TemplateBinding ItemActualHeight}"
Fill
=
"{Binding DataItem.Color}"
StrokeThickness
=
"0"
Style
=
"{TemplateBinding ItemStyle}"
/>
<
Path
x:Name
=
"PART_DefiningGeometry"
Data
=
"{TemplateBinding FigurePath2}"
Fill
=
"{Binding DataItem.Color}"
Style
=
"{TemplateBinding ItemStyle}"
/>
<
Ellipse
Clip
=
"{TemplateBinding FigurePath3}"
Fill
=
"{StaticResource PieMaskBrush}"
Width
=
"{TemplateBinding ItemActualWidth}"
Height
=
"{TemplateBinding ItemActualHeight}"
/>
</
Canvas
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
This is the static resource used for the PieMaskBrush:
<
RadialGradientBrush
x:Key
=
"PieMaskBrush"
GradientOrigin
=
"0.5,0.5"
>
<
GradientStop
Color
=
"#33FFFFFF"
Offset
=
"0.88"
/>
<
GradientStop
Color
=
"#00FFFFFF"
Offset
=
"0.65"
/>
<
GradientStop
Offset
=
"0.89"
/>
</
RadialGradientBrush
>
You may find more information about creating Color property in this help topic as the approach shown there is quite similar to the one you are following.
Best wishes,
Evgenia
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
SCRIPT5022: Unhandled Error in Silverlight Application
Code: 2531
Category: ParserError
Message: Failed to assign to property 'System.Windows.Shapes.Path.Data'.
File:
Line: 83
Position: 31
The line that gets the error is:
Data="{TemplateBinding FigurePath2}"
Help please!
We haven't faced such issue up to now with the RadChart control. Can you send us a sample stripped down version of your project where this issue reproduces so that we can investigate it locally and get back to you with our findings. Also can you clarify the version of the binaries you are getting this error with?
Best wishes,
Evgenia
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>