#12 – Markup and Code Behind
July 24, 2010 Leave a comment
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 }