Using the Rating Control in Windows Phone 7
n.b.: an update on the “half star”
For every UI framework you have a set of controls coming with it: textbox, button, listbox, etc. If you want more you need either to buy a license from third-party providers such as Telerik or develop your own custom controls which is not always trivial. Microsoft provides additional controls in a package called Silverlight Toolkit. Some will be integrated in the next release of the framework but in the meantime you can use them and — since the source code is provided — modify them.
Silverlight for Windows Phone is hardly better: since Microsoft needed to ship the mobile OS as soon as possible they were not able to ship as many controls as in the desktop version. So here is a much-needed toolkit for Windows Phone including WrapPanel, DatePicker etc.
But even the toolkit doesn’t come with all the controls shipping with the desktop version and among the missing is the rating control:
But you can grab the code and compile it on Silverlight for Windows Phone. Here’s the result of my import. You need to get all the classes from the toolkit and some from the common package. The default style is inside the generic.xaml file under the Themes folder (it’s a convention-based configuration. Since WPF all controls have their UI defined in a separate class from their behaviors).
I imported the “Half Star” style from the samples project inside the App.xaml file.
Here’s the Visual Studio project with the control.