FREE BOOK

Chapter 15: Customizing the Display

Posted by Manning Publication Free Book | Silverlight January 19, 2012
Silverlight has everything you need to format display values, convert both inbound and outbound values, provide special handling for null values and even provide fallbacks for cases when binding fails. Throughout this book, you'll see how to customize the visual representation of your data using these powerful features.

Data binding is a powerful way to show data. Occasionally, this information may be stored in a format not suitable to display in a UI. For instance, imagine asking your user, "Does two plus two equal four?" This question clearly demands a yes or no response. The problem begins to arise when the response is saved to a more persistent data source.

A lot of times, a piece of data such as a property will be saved one way but need to be presented in another. In the case of a yes-or-no question, the answer may be stored in a bool CLR property. This property may run under the assumption that "yes" is equivalent to true and "no" is the same as false. This assumption can become a problem if you need to bind to that data because, by default, data binding calls a type's ToString method. Your users could see a statement that looks like "Does two plus two equal four? True." when, in reality, it'd be better to show "Does two plus two equal four? Yes." This small but common problem demands a better approach.

If Silverlight couldn't handle the simple task of formatting values for display, binding wouldn't be particularly useful. Luckily, Silverlight has everything you need to format display values, convert both inbound and outbound values, provide special handling for null values and even provide fallbacks for cases when binding fails. Throughout this book, you'll see how to customize the visual representation of your data using these powerful features.

Total Pages : 8 12345
COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

WHITEPAPERS AND BOOKS

Trending up