Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WPF: User Controls vs Control Templates

Posted on 2009-05-08
3
Medium Priority
?
961 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 60 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 90 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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