I am working on Silverlight since 3 years and during the initial period I had a fear on creating Custom control. I was more confident creating UserControls during first one and half year of my job. But when I started working on custom controls, I came to know the power of custom control and all the fear gone out of my eyes.
It's around 2 years, I am working on it and every time I am exploring some great stuffs. Though it's a long time since Silverlight launched; still, I am seeing the same fear on others and hence decided to write a good series on it (explaining all the details), which will be beneficial for beginners.
In this tutorial part, we will discuss on "How to create a Custom Control in Silverlight". This is very basic and will be helpful for a beginner. Don't hesitate to leave your feedback at the end. If you have any query/suggestion/feedback drop a line here. I will try to answer you as early as possible.
Creating a Silverlight Application Project
First of all, we need to create a Silverlight project. Assume, you already know about it. Just for your reference, create a new project. From the left panel, select Silverlight and chose "Silverlight Application" from the right panel. Give a proper name for your application and solution. Click ok to continue.
In the next screen, just press "OK". You can chose the version of Silverlight from that screen.
Creating a Custom Control
Now once your project is ready, it's time for us to create a Custom Control. In this chapter, we will just create a default control without any additional customization. We will customize our control on later part of the series.
To do this, right click on your Silverlight project, from the context menu select "Add" and from the second level context menu click "New Item". This will open the "Add New Item" dialog box.
As shown in the below screen shot, select "Silverlight Templated Control" and give you proper name to the control. Remember that, the "Silverlight Templated Control" is the template for Custom Silverlight control.
Read more: Kunal's Blog