Binding in Blend

So far, this chapter has focused on handling binding via XAML using Visual Studio 2008. Visual Studio 2008 makes writing XAML easy through its IntelliSense and other text-editing features. However, Expression Blend is also a very viable tool for creating Silverlight 2 applications. Expression Blend shows both the XAML and a visual designer in a split screen. Though Expression Blend currently lacks some of the IntelliSense and other text-editing features that are inherent in Visual Studio 2008, it has a much richer designer. This makes Blend a great choice for designing Silverlight applications. An ideal choice is to use both Blend and Visual Studio 2008 to edit a Silverlight project at the same time.

Besides basic designer features, Blend also provides ways to create event handlers and establish data binding. This makes it easy to use Blend to design a user control and bind its child controls to a binding source. First, to demonstrate this example, Figure 2-9 shows a user control that is created through Blend.

Creating a user control in Expression Blend

Figure 2-9. Creating a user control in Expression Blend

Next, you can add the code to the code-behind for the BlendBinding.xaml user control. You can do this by right-clicking the BlendBinding.xaml.cs file in the project window in Blend and selecting the Edit in Visual Studio menu option, as shown in Figure 2-10.

Figure 2-10. Editing a file in Visual Studio ...

Get Data-Driven Services with Silverlight 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.