Solved

WPF: User Controls vs Control Templates

Posted on 2009-05-08
3
953 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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