Appendix A. XAML Primer

Chapter 1 exposed you to the fundamentals of building Silverlight applications. You were introduced to XAML, which is the glue between the interactive user interfaces you create and the managed code you write. This appendix explores more details of XAML and gives you a primer on XAML that can serve as a reference as you work through the book.

INTRODUCING XAML

As you learned in Chapter 1, XAML finally provides a unified markup that can describe not only what a control is and how it fits into a page, but also how layout and, more importantly, the overall look and feel of the controls on a page are defined. A designer can use XAML to create a mockup of a page or an application, and a developer can take that XAML markup and use it directly in his project files. Because partial classes and code-behind files in Visual Studio allow you to separate the code logic from the layout and control definitions, using XAML gives the opportunity to have this separation of the design from the code. Look at the following XAML example, which demonstrates an animation on a TextBlock element:

<Canvas
    Width="640" Height="480"
    Background="White">
        <Canvas.Triggers>
            <EventTrigger RoutedEvent="Canvas.Loaded">
                <BeginStoryboard>
                    <Storyboard x:Name="Timeline1"/>
                </BeginStoryboard>
            </EventTrigger>
        </Canvas.Triggers>

        <TextBlock Width="349" Height="67"
            Canvas.Top="140" Text="Hello World"
            TextWrapping="Wrap"
            RenderTransformOrigin="0.5,0.5"
            x:Name="textBlock">
            <TextBlock.RenderTransform>
<TransformGroup> ...

Get Professional Silverlight® 4 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.