この手順では、最初に Visual Studio で PdfViewer for UWP を使用する UWP スタイルのアプリケーションを作成します。プロジェクトをセットアップし、C1PdfViewer コントロールをアプリケーションに追加するには、次の手順に従います。
XAMLでマークアップを書く場合
マークアップ |
コードのコピー
|
---|---|
<Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> |
グリッド内の要素が配置されて表示されます。
XAMLでマークアップを書く場合
マークアップ |
コードのコピー
|
---|---|
<PdfViewer:C1PdfViewer x:Name="pdfViewer" ViewMode="FitWidth"Grid.Row="1"Grid.ColumnSpan="2"/> |
このマークアップは、コントロールに名前を付け、コントロールに PDF の幅全体が表示されるように ViewMode を設定し、コントロールのレイアウトをカスタマイズします。
XAMLでマークアップを書く場合
マークアップ |
コードのコピー
|
---|---|
<StackPanel Orientation="Horizontal" Margin="8" VerticalAlignment="Center"> <TextBlock Text="{Binding ElementName=pdfViewer, Path=PageNumber}" FontSize="20" Foreground="{StaticResourceApplicationForegroundThemeBrush}" /> <TextBlock Text=" / " Foreground="{StaticResource ApplicationForegroundThemeBrush}" FontSize="20"/> <TextBlock Text="{Binding ElementName=pdfViewer, Path=PageCount}" FontSize="20" Foreground="{StaticResourceApplicationForegroundThemeBrush}" /> </StackPanel> |
このマークアップは、StackPanel に3つの TextBlock コントロールを追加します。
XAMLでマークアップを書く場合
マークアップ |
コードのコピー
|
---|---|
<Button x:Name="btnLoad" Grid.Column="1" Content=" Load Pdf... " HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8" Click="btnLoad_Click" /> |
これで、UWP スタイルのアプリケーションを作成できました。次の手順では、PDF を表示するコードをアプリケーションに追加します。