0
지도와 데이터를 DataGrid에 표시하는 사용자 정의 컨트롤이 하나 있습니다.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 (새 사각형 (새 포인트 (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- wpf-window-that-scrolls? forum = wpf)이 줄들을 찾으십시오. dlg.PrintVisual (panel.Content, "Print Button"); –