In the previous step you created a new Windows Phone Application. In this step you'll add code to your application to finalize the application.
Complete the following steps:
1. In the XAML window of the project, place the cursor between the <Grid x:Name="ContentPanel"></Grid> tags and click once.
2. Add the following XAML markup cursor between the <Grid x:Name="ContentPanel"></Grid> tags to add a StackPanel containing a Button to the application:
<StackPanel VerticalAlignment="Center">
<Button Content="Open Popup" Height="72" HorizontalAlignment="Center" Margin="10,10,0,0" Name="btnOpen" VerticalAlignment="Top" Width="200" Click="btnOpen_Click" />
</StackPanel>
Note that you'll add code for the button's Click event handler later.
3. Add the following markup between the </StackPanel> and </Grid> tags to add a C1Popup control with content to your application:
<c1:C1Popup x:Name="c1Popup1">
<!--Content here-->
<StackPanel>
<TextBlock Text="Select an option:" Margin="15" />
<RadioButton x:Name="radio1" Content="Option 1" />
<RadioButton x:Name="radio2" Content="Option 2" />
<RadioButton x:Name="radio3" Content="Option 3" />
<Button Content="Close Popup" Width="200" x:Name="btnClose" Click="btnClose_Click" />
</StackPanel>
</c1:C1Popup>
Note that the C1Popup control contains text and buttons. In the next steps you'll add code to initialize one of the buttons.
Your complete markup will appear like the following:
<phone:PhoneApplicationPage
x:Class="C1WP.MainPage"
xmlns:c1="clr-namespace:C1.Phone;assembly=C1.Phone"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="ComponentOne Studio for Windows Phone" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Popup" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel VerticalAlignment="Center">
<Button Content="Open Popup" Height="72" HorizontalAlignment="Center" Margin="10,10,0,0" Name="btnOpen" VerticalAlignment="Top" Width="200" Click="btnOpen_Click" />
</StackPanel>
<c1:C1Popup x:Name="c1Popup1">
<!--Content here-->
<StackPanel Background="DarkSlateBlue">
<TextBlock Text="Select an option:" Margin="15" />
<RadioButton x:Name="radio1" Content="Option 1" />
<RadioButton x:Name="radio2" Content="Option 2" />
<RadioButton x:Name="radio3" Content="Option 3" />
<Button Content="Close Popup" Width="200" x:Name="btnClose" Click="btnClose_Click" />
</StackPanel>
</c1:C1Popup>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
4. Select View | Code to switch to Code view.
5. Add the following Click event handler to the code:
Private Sub btnOpen_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnOpen.Click
' open popup
c1Popup1.IsOpen = True
End Sub
Private Sub btnClose_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
' close popup
c1Popup1.IsOpen = False
End Sub
•C#
private void btnOpen_Click(object sender, RoutedEventArgs e)
{
// open popup
c1Popup1.IsOpen = true;
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
// close popup
c1Popup1.IsOpen = false;
}
These buttons will open and close the C1Popup control.
In this step you added the C1Popup control your application. In the next step you'll run the application and observe run-time interactions.