|
Silverlight 4 在 Silverlight 功能列表中添加了打印,我想通過(guò)向您介紹令我欣慰的小程序來(lái)探討這一點(diǎn)。
該程序稱(chēng)為 PrintEllipse,名稱(chēng)就是它要執(zhí)行的所有操作。 MainPage 的 XAML 文件包含一個(gè)按鈕,圖 1 中完整地顯示了 MainPage 代碼隱藏文件。
圖 1 PrintEllipse 的 MainPage 代碼
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Printing;
using System.Windows.Shapes;
namespace PrintEllipse
{
publicpartialclass MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
void OnButtonClick(object sender, RoutedEventArgs args)
{
PrintDocument printDoc =new PrintDocument();
printDoc.PrintPage += OnPrintPage;
printDoc.Print("Print Ellipse");
}
void OnPrintPage(object sender, PrintPageEventArgs args)
{
Ellipse ellipse =new Ellipse
{
Fill =new SolidColorBrush(Color.FromArgb(255, 255, 192, 192)),
Stroke =new SolidColorBrush(Color.FromArgb(255, 192, 192, 255)),
StrokeThickness =24// 1/4 inch
};
args.PageVisual = ellipse;
}
}
}
NET技術(shù):Silverlight 打印基礎(chǔ)知識(shí),轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。