我是C#的新手。我目前正在使用WPF开发一个自助服务终端软件。
我想在画布里面打印一张纸条,我创建了一个白色背景的画布来打印它。
以下是我要打印的代码:
//The address read from user input
COAChequeChequeAddress1Printed.Content = premiseType + " " + premiseNo + " " + premiseName;
COAChequeChequeAddress2Printed.Content = streetOne;
COAChequeChequeAddress3Printed.Content = streetTwo;
COAChequeChequeAddress4Printed.Content = poskod + " " + area + " " + town;
COAChequeChequeAddress5Printed.Content = state;
COAChequeContactNumberPrinted.Content = contactNo;
COAChequePrintedImage.Background = new ImageBrush(new BitmapImage(new Uri(Properties.Settings.Default.ICChequeImagePath)));
if ((bool)Printdlg.ShowDialog().GetValueOrDefault())
{
COAChequeFormPrinted.Visibility = Visibility.Visible;
//Printdlg.PrintVisual(COAChequeFormPrinted, "COA Cheque FORM");
//Hide every form and show print success page
COAChequeFormPrinted.Visibility = Visibility.Hidden;
COAFormCheque.Visibility = Visibility.Hidden;
COAFormTransfer.Visibility = Visibility.Hidden;
printCOAChequeForm.Visibility = Visibility.Hidden;
printCOATransferForm.Visibility = Visibility.Hidden;
PrintingMessageCanvas.Visibility = Visibility.Visible;
}
如果我注释掉if ((bool)Printdlg.ShowDialog().GetValueOrDefault())
它不会提示打印对话框,但我的画布标签的内容在打印时会变空。
如果我使用了showdialog函数,那么我的所有画布标签内容都会在打印时显示。
我可以在设置中更改任何内容,或者任何代码都可以提供帮助吗? 请指导我完成这个。感谢