Solved

WPF: User Controls vs Control Templates

Posted on 2009-05-08
3
946 Views
Last Modified: 2013-11-12
I am trying to figure out what the main difference is between a User Control and a Control Template.  It seems that in both cases I can specify what controls I want to use since the Control Template allows me to change the entire visual tree of the control I am templating, but the User Control allows me to define what controls I want to include as well.  What is the main difference here?
0
Comment
Question by:AdamEscobedo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Assisted Solution

by:lulu2005
lulu2005 earned 20 total points
ID: 24337726
Two things comes up into my mind is:

The user control can
  • let you define your own events and where and how to trigger it.
  • let you define the interactions among the controls.
0
 
LVL 16

Expert Comment

by:ToddBeaulieu
ID: 24337845
I agree with lulu. You can do more with a user control, since you're defining not only a group of controls (potentially), but also the code behind, including event handling, etc.

The biggest factor in deciding to make a UC, though, is whether you're going to reuse it. There's little sense, IMO, in creating a user control for one time use.
0
 
LVL 1

Accepted Solution

by:
aweilee earned 30 total points
ID: 24345469
The main difference between user controls and templates is that using a template you can completely change an existing control throughout your application without even needing to change anything else than App.xam. Imagine turning all of the ComboBox controls into spinning 3D carousels: you can do exactly this with templates by modifying just the App.xaml file.

Creating a user controls that would be used in place of your ComboBox, in the above example, means you would need to replace every occurrence of the ComboBox control with a declaration of your user control everywhere. While this can be acceptable for an application that's under development, you definitely don't want to do this in an already developed application.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Alternative to visual sourcesafe 2 154
Dialogbox API leak? 18 119
Recommendation vb6 to vb.net or others 14 241
Problem to open text file 11 147
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question