This is a mirror of official site: http://jasper-net.blogspot.com/

So what's the difference between Custom Control and User Control?

| Monday, April 11, 2011
That's a good question came up after the series in my blog. Someone asked why should one use Custom Control instead of User Control? Hence, let's extend the series and discuss about that. I apologise the delay of this post. I should explain this at the start of the series, but actually my goal was to explain you how to create and use Custom Control in Silverlight.
 
It is better to do it later than never. Also, you are now familiar with Custom Control creation. Hence, start describing it. You will come to know more about this here. As always, don't forget to share your feedback at the end of this page.
 

What is Custom Control?

A custom control is a loosely coupled control defined in a class, which derives from Control. The UI of custom control generally defined in a Resource Dictionary inside the resource file. We can create themes for custom control and reuse them in various projects very easily.
 
Button, CheckBox, TextBox etc. even a UserControl is nothing but a Custom Control. You can easily load them inside a XAML page.

image%5B3%5D.png?imgmax=800

A Custom control generally inherits from System.Windows.Controls.Control class. You may derive from a different custom control also depending on your requirement.
 
Custom Controls are compiled into a dll assembly and can be reused in multiple places very easily. You have total control over it's code, thus gives you more flexibility to extend the behaviour. Once you build and add reference of custom control in your project, you can find it in the toolbox. Thus, you will be able to drag and drop the control in your design view and start working with that very easily.
 
 
 
What is User Control?

The base "UserControl" is nothing but a Custom Control that you derive to create control UI specific to your project. Generally we create a UserControl which placed inside a XAML page with tightly bonding to it's code behind. You can directly access it's UI elements from code behind and do some specific operations.

q1Mb8QrX4xVuAaIzIS3qjYRe4L9eFLbYvDBiA73hsciXUuwXGCNzUkCBRnO58QGOfv7pxP0LCviSFgM22b2IWcayQIsCCNBD2+doIiwII0QTvmvHFLRBPj9rqm8waVsXeUBWnsMeYaxh0Bu6mVcXeCKzwfETCmwViNzknvsSCdE9i5UkaAEWAEGAErAv8fJ6uC17HAcb0AAAAASUVORK5CYII=

Read more: Kunal's Blog

Posted via email from Jasper-net

0 comments: