Reputation: 20697
I'm not very clear of when to use a CustomControl and when to use an UserControl. I basically know what CustomControl allow(more customization when using with template).
I want to make a "File browse" control in WPF(TextBlock that displays the current path + Button that trigger a "Open File Dialog").
I'm not sure, because at some places I find that they say this should always "replace" a WPF control. I was more thinking that a a CustomControl was more like a way to display and edit one new semantic value (in my case, a "File(path)").
So, if we don't take into account which one is easier to do, what would be the more adequate between CustomControl and UserControl for the "FileBrowse" control that I'm speaking about?
Thank you
Upvotes: 3
Views: 2257
Reputation: 3018
Custom Control:
User Control :
When we talk about differences, it is more important to emphasis on the context when to use what:
Upvotes: 6
Reputation: 308
I think a UserControl
is the one to choose, for it is used for a kind of "assembly of existing controls". In your case a button and a file open dialog. It will then get a specific look and feel (for example the default look of a button and the default look of a file open dialog).
The CustomControl
is kind of the other way round. It has no look and feel by itself. It is completely abstract concerning layout. The layout comes into play, wwhen assigning a style to it.
Upvotes: 1
Reputation: 16119
In general a custom control extends an existing control while a user control creates a new control type from a collection of existing controls. I would say that a user control is better suited, based on the information you've given.
Upvotes: 0