Hi all,
In Map Suite Web Ajax Edition, there is a "Print a Map" sample, but not on Map Suite Silverlight Edition!
Please, help me with a sample on Silverlight! Thanks in advance!
Hi all,
In Map Suite Web Ajax Edition, there is a "Print a Map" sample, but not on Map Suite Silverlight Edition!
Please, help me with a sample on Silverlight! Thanks in advance!
Hi Tran,
Sorry our silverlight edition don’t have a print function.
But you can implement that like this:
public partial class Sample : UserControl
{
public Sample()
{
InitializeComponent();
}
private void Map1_Loaded(object sender, RoutedEventArgs e)
{
Map1.CurrentExtent = new RectangleShape(-132, 55, -70, 20);
Map1.MapUnit = GeographyUnit.DecimalDegree;
WorldMapKitWmsSilverlightOverlay baseOverlay = new WorldMapKitWmsSilverlightOverlay();
Map1.Overlays.Add(baseOverlay);
Map1.Refresh();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Map1.Print();
}
}
public static class MapPrintExtension
{
public static void Print(this Map map, string documentName = “MapSuite Print Demo”)
{
PrintDocument printDoc = new PrintDocument();
printDoc.PrintPage += new EventHandler<PrintPageEventArgs>((s, e) => e.PageVisual = map);
printDoc.Print(documentName);
}
}
There are two things need notice here:
1. Don’t add breakpoint when you try print, orelse you will get the “Dialogs must be user-initiated.” exception. Remove breakpoint when debug will make that works.
2. Make sure your Silverlight version is 4.0 or higher.
Wish that’s helpful.
Regards,
Don