Tuesday, January 18, 2011

Adding a New Page to a Multi-Page Silverlight Application

So, you've started building a Silverlight Line of Business (LOB) application using the Silverlight Navigation Application template (as shown in this prior post). This post covers how to add pages to it.
NOTE: This post is part of a series that starts with this prior post.

1) Add a new Page by right-clicking on the Views folder and selecting Add | New Item. Then pick the Silverlight Page template under the desired language: VB or C#.

0675.image_5F00_thumb_5F00_5FC01742.png

2) Add any desired controls to the page.

3) Modify MainPage.xaml to include an additional HyperlinkButton to display the new page. The changes are shown in red:

<UserControl
   x:Class="InStepSM.SL.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
   xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
       <Grid x:Name="LayoutRoot">
           <Border x:Name="ContentBorder"
                Style="{StaticResource ContentBorderStyle}">
               <navigation:Frame x:Name="ContentFrame"
                   Style="{StaticResource ContentFrameStyle}"
                   Source="/Home" Navigated="ContentFrame_Navigated"
                   NavigationFailed="ContentFrame_NavigationFailed">
                   <navigation:Frame.UriMapper>

Read more: Deborah's Developer MindScape