0
マップとデータをデータグリッドに表示するユーザーコントロールが1つあります。C#を使用してwpfユーザーコントロールのプリントを取る方法は?
私は次のコードを試しましたが、動作しません。
PrintDialog printDialog = new PrintDialog();
// if user clicks on cancel button of print dialog box then no need to print the map control
if (!(bool)printDialog.ShowDialog())
{
return;
}
else // this means that user click on the print button
{
// do nothing
}
this.Measure(new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight));
this.Arrange(new Rect(new Point(20, 20), new Size(this.ActualWidth, this.ActualHeight)));
// print the map control
printDialog.PrintVisual(this, "Karte drucken");
問題:データグリッドは、多数のレコードを持っている場合、ユーザーコントロールがスクロールバーを取得しますが、ユーザーコントロールを印刷した後、ユーザーコントロールの唯一の目に見える部分が印刷されていない、我々は後に見ることができるデータの存在スクロールダウンします。私はユーザーコントロールの全内容を印刷したいと思います。
これには解決策はありますか?また、どのようにwpfで印刷プレビューを見ることができますか?
おかげで、私は「userControl.Arrange(新しいのRect(新しいポイント(50、50)、新しいサイズ(userControl.ActualWidth、userControl.ActualHeightを使用して問題を解決しました)))); ") "新しいRect(新しい点(50,50)、新しいサイズ(userControl.ActualWidth、userControl.ActualHeight))))の代わりに" dategrid.Arrange "私は今新しい問題に直面している、私は質問を更新しました – pankaj
@pankajこのスレッドを見てください[リンク](https://stackoverflow.com/questions/3009575/wpf-best-method-for-printing-paginated-datagrids) –
@pankajもこのmsdnの記事を参照してください。[リンク](https://social.msdn.microsoft.com/Forums/vstudio/en-US/be2edad6-f075-4295-ab22-3657eba78043/how-to-print-the- dlg.PrintVisual(panel.Content、 "Print Button"); 'dlg.PrintVisual(panel.Content、" Print Button ");これらの行を探します。 –