2008-11-05 86 views

回答

21
var bi = new BitmapImage(); 
bi.BeginInit(); 
bi.CacheOption = BitmapCacheOption.OnLoad; 
bi.UriSource = new Uri(""); 
bi.EndInit(); 

var vis = new DrawingVisual(); 
var dc = vis.RenderOpen(); 
dc.DrawImage(bi, new Rect { Width = bi.Width, Height = bi.Height }); 
dc.Close(); 

var pdialog = new PrintDialog(); 
if (pdialog.ShowDialog() == true) { 
pdialog.PrintVisual(vis, "My Image"); 
} 
+0

塔米爾......其優良....如果我需要打印多個圖像...,我怎麼能實現呢? – 2013-08-27 06:44:12

1

只需加載圖像並將其應用於視覺效果。然後使用PrintDialog來完成這項工作。

... 
PrintDialog printer = new PrintDialog(); 

if (printer.ShowDialog()) { 
    printer.PrintVisual(myVisual, "A Page Title"); 
}