Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - What is the difference between DataTemplate and ControlTemplate

 
 
Old 05-17-2006   #1 (permalink)
Daniel


 
 

What is the difference between DataTemplate and ControlTemplate

Hi, everyone

Can anyboday tell me why it is nessary for both DataTemplate
and ControlTemplate to exist?

Thanks.


My System SpecsSystem Spec
Old 05-17-2006   #2 (permalink)
qazxsw


 
 

Re:What is the difference between DataTemplate and ControlTemplate

datatemplate is how to style the data and controltemplate is to style the
control(how the control looks
My System SpecsSystem Spec
Old 05-17-2006   #3 (permalink)
Marcus


 
 

Re: What is the difference between DataTemplate and ControlTemplate

More Specifically:

A ControlTemplate is used to define/change the way a class derived from
Control looks...

Buttons, ListBox, ScrollBar, ...

However, some "Controls" you use are not derived from Control: Best
example is the TextBlock class. The TextBlock cannot have a
ControlTemplate.

Alternatly, the concept of DataTemplate is closelly linked with the
Content Model in WPF application.

Certain controls are made to display "Content"... The content can be
anything... An Image, Text, an Object.... in fact, it is defined as an
"object" type.

The DataTemplate simply defines how a particular content (or content
type) is meant to be displayed... Example: Usually, a string is
displayed using a simple TextBlock... However, if you want a custom
text layout, decoration, alignement, ... you would need to define an
Alternate DataTemplate.

I hope this clears the topic a little more...

My System SpecsSystem Spec
Old 05-19-2006   #4 (permalink)
Daniel


 
 

Re: What is the difference between DataTemplate and ControlTemplat

Ok, I've understood it to some extent.
Thanks a lot.
My System SpecsSystem Spec
Old 05-19-2006   #5 (permalink)


 
 

Just wanted to add that you can take a look at the before/after screenshots at the top and the bottom of this page: http://windowssdk.msdn.microsoft.com...75ec07da2e.asp

The ListBox at the top... a ControlTemplate is used to define the visuals of ListItems (what the Border looks like, what happens when an item is selected). A DataTemplate is used to describe how the Photo objects (the content/data items) should be displayed (in this case, as images instead of filenames).

Hope this helps,
Tina
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
DataTemplate .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46