Solved

WPF: User Controls vs Control Templates

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

Assisted Solution

by:lulu2005
lulu2005 earned 20 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now