Here is part 3 of Josh Twist's 10 part series on the reasons to consider WPF for your next desktop application, this part explores the topic of DataTemplates.
Earlier I introduced a series of posts entitled 10 reasons to consider WPF for your next desktop application. If you haven't read the intro yet, better head on back and read it first.
You could consider the power of this point to really be the combination of the previous two points (Rich Content Model and Databinding) but nonetheless, DataTemplates definitely deserve a reason of their own.
MSDN describes the DataTemplate thus:
"You use a DataTemplate to specify the visualization of your data objects. DataTemplate objects are particularly useful when you are binding an ItemsControl such as a ListBox to an entire collection. Without specific instructions, a ListBox displays the string representation of the objects in a collection. In that case, you can use a DataTemplate to define the appearance of your data objects. The content of your DataTemplate becomes the visual structure of your data objects."
We're going to use the same simple form that we used in the Reason 2 example and pimp it up!
Now this is cool. And notice that if I change the value of the Customer Rating, the bar automatically changes too!
Why not have a play with the Reason 3 ClickOnce Sample.
IMPORTANT NOTE - the customer ratings used in these examples are totally random and do not necessarily reflect my, or anybody elses for that matter, actual opinion!
Originally Posted by Josh Twist on 17 Oct 2007 here.