#12 – Markup and Code Behind

WPF applications are made up of markup (XAML) and code-behind (managed code).  The markup defines the layout and appearance of the application, whereas the code-behind defines the behavior.

WPF markup is written using XAML, a declarative markup language based on XML.  The XAML lists the controls that make up the application, how they are related, and how they appear.

<Grid>
    <StackPanel>
        <Button Content="Save" Height="23" Name="btnSave" Width="75" Click="btnSave_Click" />
        <Button Content="Load" Height="23" Name="btnLoad" Width="75" Click="btnLoad_Click" />
    </StackPanel>
</Grid>

The code-behind is the part of your application that exists as managed code (e.g. C#) and describes the behavior of the application at runtime.

private void btnSave_Click(object sender, RoutedEventArgs e)
{
    // Do actual work of saving file here
}
About these ads

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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 351 other followers

%d bloggers like this: