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
skin able
|
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 in depth
knowledge of the UI Model
|
Hope you now have a
better understanding from the above comparison table.
When to use?
Good question:
"When to use a Custom Control?" Haven't you got the inner meaning of
it yet? OK, read the summarized points below:
·
When you have a rapid
and fixed content in your UI, use UserControl.
·
When you want to separate
some basic functionality of your main view to some smaller pieces with
reusability, use UserControl.
·
When you want to use
your control in different projects and each project may want to change the
look, use CustomControl.
·
When you want to
implement some additional functionality for a control, create a CustomControl
derived from the base control.
·
When you want to apply
themes to your controls, use CustomControl.
·
When you want to add
toolbox support for your control, so that your user will be able to do drag and
drop to the designer, use CustomControl.
No comments:
Post a Comment