O'Reilly logo

Silverlight 4 Data and Services Cookbook by Kevin Dockx, Gill Cleeren

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using templates to customize the way data is shown by controls

Normally when we ask Silverlight to visualize an object, for example a person or a customer, it will simply display the result of the ToString() method—which is, of course, a string. This can be seen when we're binding a collection of items to a ListBox. If we don't specify a value for the DisplayMemberPath property, we simply see the name of the type (unless we overloaded the ToString() method). However, it's possible to specify a template called a DataTemplate, which will be used to visualize an object. It's in fact nothing more than a block of XAML code that gets rendered when an item of a particular type is visualized.

In this recipe, we'll build a DataTemplate to render the activities ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required