Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
DataTemplates_Tutorial_07_CS

DataTemplates_Tutorial_07_CS

Ratings: (0)|Views: 16|Likes:
Published by api-19796528

More info:

Published by: api-19796528 on Nov 29, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

DataBinding & DataTemplates Using Expression Blend

In Tutorial #2, Data Binding, we explored how to bind relatively simple data to relatively simple
controls. This tutorial will dive a bit deeper, looking specifically at two topics that are of
particular importance in DataBinding:

\u2022
Binding complex objects to List controls
\u2022
Using Expression Blend vs. Creating bindings in Xaml by hand

While we did have a list of chapter names that we bound to a list box in the previous chapter that was not quite complex enough to raise the question of DataTemplates; in this tutorial we'll look at what happens when you bind more complicated objects, that have numerous properties, to a list control.

The Finished Product
To get an idea of where we are going, and what pieces will be important, let's take a look at some
aspects of the finished product.
Figure 7-1. ListBox with Data From Books

A quick look at Figure 7-1 shows that we're listing each book in a collection, formatting the
name in red and Comic Sans MS, 16 point, while we're formatting the rest of the line, which
includes the Book's ISBN and cover price in Verdana, black, 14 point. How we are doing that is
not yet obvious. Nor is it obvious where the information (book title, ISBN or price) is coming
from.

It gets more interesting when you click on a particular book in the list as shown in Figure 7-2
Figure 7-2. Book Details

When the user clicks on a book it is highlighted, and the list box literally shrinks down to make
room for the details about the book. What is now visible is 6 rows of information about the book,
including a list of authors bound to a smaller list box, a few rows of strings and integers, and a
rating displayed both in a slider and a TextBlock.

Leveraging Expression Blend with Visual Studio

This tutorial will show how to create bindings both to lists and to individual controls using
Blend; giving you more leverage, more quickly, and, like any good development environment,
allowing you to focus on what you are trying to build rather than on the specific syntax of
building it.

This tutorial will not recapitulate the concepts covered in Tutorial #2, but we will introduce a
few new UI concepts that Blend makes easy to implement.
Creating the Project
To get started, create a new project, in Blend, called Silverlight Data as shown in Figure 7-3
Figure 7-3. Creating a new project in Blend
Once the project is created, set the outermost user control to 680 x 550 and create three rows, as
shown in Figure 7-4
Figure 7-4. Creating three rows in Blend
If you are not comfortable with how to create these rows in Blend, you'll want to pause here and
read Tutorial #5 on Expression Blend for Developers

Activity (4)

You've already reviewed this. Edit your review.
1 hundred reads
ameshlal liked this
peterangka liked this
peterangka liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->