Custom controls are basically compiled code i.e. DLLs. These can be easily added to toolbox, so it can be easily used across multiple projects using drag and drop approach. These controls are comparatively hard to create.
But User Controls (.ascx) are just like pages (.aspx). These are comparatively easy to create but tightly couple with respect to User Interface and code. In order to use across multiple projects, we need to copy and paste to the other project as well.Difference between a CustomControl and a UserControl
So now you have got the difference between a Custom Control and a User Control, I guess. Let's summarize the differences again. Read the comparison below to make things clear:
| Custom Control | User Control |
| A loosely coupled control w.r.t code and UI | A tightly coupled control w.r.t code and UI |
Derives from Control | Derives from UserControl |
Defines UI in a ResourceDictionary | Defines UI as normal XAML |
| UI is skinable | Child controls are skinable |
| Has dynamic layout | Has static layout |
| UI can be changed in different projects | UI is fixed and can't have different looks in different project |
| Has full toolbox support | Can't be added to the toolbox |
| Defines a single control | Defines a set of controls |
| More flexible | Not very flexible like a Custom Control |
| Requires in-depth knowledge of Silverlight UI Model | Does not require indepth knowledge of the UI Model |
Hope you now have a better understanding from the above comparison table.
.jpg)
No comments:
Post a Comment