PdfViewer for WinRT > Getting Started with WinRT Edition > Quick Start > Step 1 of 3: Adding C1PdfViewer to the Application |
In this step you'll begin in Visual Studio to create a WinRT-style application using PdfViewer for WinRT. To set up your project and add a C1PdfViewer control to your application, complete the following steps:
Markup Copy Code<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>Elements in the grid will now appear positioned.
To write the markup in XAML:
Markup Copy Code <PdfViewer:C1PdfViewer x:Name="pdfViewer" ViewMode="FitWidth" Grid.Row="1" Grid.ColumnSpan="2"/>
This markup gives the control a name, sets the ViewMode of the control so that the entire width of a PDF will be displayed in the control, and customizes the layout of the control.
To write the markup in XAML:
Markup Copy Code <StackPanel Orientation="Horizontal" Margin="8" VerticalAlignment="Center" > <TextBlock Text="{Binding ElementName=pdfViewer, Path=PageNumber}" FontSize="20" Foreground="{StaticResource ApplicationForegroundThemeBrush}" /> <TextBlock Text=" / " Foreground="{StaticResource ApplicationForegroundThemeBrush}" FontSize="20"/> <TextBlock Text="{Binding ElementName=pdfViewer, Path=PageCount}" FontSize="20" Foreground="{StaticResource ApplicationForegroundThemeBrush}" /> </StackPanel>
This markup adds three TextBlock controls in the StackPanel.
To write the markup in XAML:
Markup Copy Code <Button x:Name="btnLoad" Grid.Column="1" Content=" Load Pdf... " HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8" Click="btnLoad_Click" />
You've successfully created a WinRT-style application. In the next step you'll add code to the application to view a PDF.