#56 – XAML

XAML (eXtensible Application Markup Language) is a markup language used when creating WPF or Silverlight applications to define aspects of the application’s appearance or behavior declaratively.  XAML is based on XML and uses XML-like syntax.

In WPF and Silverlight, you typically define your entire user interface using XAML.  Here’s an example, defining a window that contains a panel which in turn contains two buttons.

<Window x:Class="WpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="224" Width="334">
    <StackPanel Orientation="Horizontal">
        <Button Name="button1" Content="OK" Height="23" Width="75" />
        <Button Name="button2" Content="Cancel" Height="23" Width="75" />
    </StackPanel>
</Window>

XAML tags (e.g. Window, Button) map directly to instances of CLR objects and XAML attributes map to properties and events for those objects.   In this example, we’ve created two instances of the Button class, with values of “OK” and “Cancel” for their Content properties.

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 131 other followers