We will start developing a simple control sample and gradually expand it to demonstrate all the required concepts.
The resulting sample application is located under CODE\SpinningControlSample\SpinningControlSample.sln
, but we recommend that you build this sample from scratch, based on the instructions within this chapter.
The goal of this sample is to develop a
lookless control that has a RotationAngle
dependency property and later to provide a view for this control (for example, as a rectangle), and to animate the RotationAngle
so that the rectangle would be seen as rotating.
Lookless controls are controls that do not contain any visual implementation details. Such controls need a ControlTemplate
in order to display them. This provides a great advantage to developers/designers because it separates the control's implementation details from its presentation.
Firstly, let's create a Silverlight Application project called SpinningControlSample
. Follow the instructions in Appendix A, Creating and Starting a Silverlight Project, to create a browser-based, empty Silverlight solution. As mentioned in Appendix A, the solution will actually contain two projects, SpinningControlSample
and SpinningControlSample.Web
. The project with the .Web
extension is just an ASP project to embed the Silverlight page. We are not going to concentrate on it. The real project of interest to us is SpinningControlSample
.
Within the SpinningControlSample
project, we create a new empty C# class, SpinningControl
.
Make the SpinningControl
class inherit from the Control
class as shown in the following code snippet:
public class SpinningControl : Control { }
We are going to populate this class to provide the functionality that is previously described.