【发布时间】:2011-07-06 07:30:35
【问题描述】:
大多数 WPF 打印示例都是这样的:
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
StackPanel myPanel = new StackPanel();
myPanel.Margin = new Thickness(15);
Image myImage = new Image();
myImage.Width = dialog.PrintableAreaWidth;
myImage.Stretch = Stretch.Uniform;
myImage.Source = new BitmapImage(new Uri("pack://application:,,,/Images/picture.bmp"));
myPanel.Children.Add(myImage);
myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));
dialog.PrintVisual(myPanel, "A Great Image.");
}
我不喜欢的是,他们总是将边距设置为固定值。 但是在 PrintDialog 中,用户可以选择没有样本关心的单个边距。如果用户现在选择一个较大的边距作为程序设置的固定边距,则打印输出被截断。 有没有办法从 PrintDialog 获取用户选择的边距值?
TIA 迈克尔
【问题讨论】: