I’m working on printing the map and I’m running into some issues. I’m currently working on a simple application to limit the factors involved. The code below brings up a print preview window, but after I close it and click on the map I get an unhandled exception: “Printer layer supports Feet or Meter only”. I have used similar code to this to do a print preview on the GoogleMapsLayer successfully. Some of this code is based on the LargeScaleMapPrinting example.
private void wpfMap1_Loaded(object sender, RoutedEventArgs e)
{
  wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
  WorldMapKitLayer lTest = new WorldMapKitLayer(WorldMapKitLayerType.WorldMapKitLayer, <clientid>, <private key>);
  lTest.MapType = WorldMapKitMapType.AerialWithLabels;
  LayerOverlay overlayThinkGeo = new LayerOverlay();
  overlayThinkGeo.Name = "ThinkGeo";
  overlayThinkGeo.Layers.Add(lTest);
  wpfMap1.Overlays.Add(overlayThinkGeo);
  LayerOverlay overlayCache = new LayerOverlay();
  overlayCache.Name = "TileCache";
  overlayCache.TileType = TileType.MultipleTile;
  overlayCache.TileCache = new FileBitmapTileCache(<cache path>, <cache id>);
  wpfMap1.Overlays.Add(overlayCache);
  PrinterInteractiveOverlay printerInteractiveOverlay = new PrinterInteractiveOverlay();
  wpfMap1.InteractiveOverlays.Add("PrintPreviewOverlay", printerInteractiveOverlay);
  wpfMap1.InteractiveOverlays.MoveToBottom("PrintPreviewOverlay");
  PagePrinterLayer pagePrinterLayer = new PagePrinterLayer(PrinterPageSize.AnsiA, PrinterOrientation.Portrait);
  pagePrinterLayer.Open();
  printerInteractiveOverlay.PrinterLayers.Add("PageLayer", pagePrinterLayer);
}
private void button_Click(object sender, RoutedEventArgs e)
{
  RectangleShape rOrigExtent = wpfMap1.CurrentExtent;
  GeographyUnit eOrigUnit = wpfMap1.MapUnit;
  wpfMap1.MapUnit = GeographyUnit.Meter;
  PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)wpfMap1.InteractiveOverlays["PrintPreviewOverlay"];
  PagePrinterLayer pagePrinterLayer = (PagePrinterLayer)printerInteractiveOverlay.PrinterLayers["PageLayer"];
  foreach (Overlay o in wpfMap1.Overlays)
  {
    MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();
    mapPrinterLayer.MapUnit = eOrigUnit;
    mapPrinterLayer.MapExtent = rOrigExtent;
    mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 1));
    mapPrinterLayer.Open();
    RectangleShape pageBoundingbox = pagePrinterLayer.GetPosition(PrintingUnit.Inch);
    mapPrinterLayer.SetPosition(7, 10, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y, PrintingUnit.Inch);
    foreach (Layer l in ((LayerOverlay)o).Layers)
    {
      mapPrinterLayer.Layers.Add(l);
    }
    printerInteractiveOverlay.PrinterLayers.Add(mapPrinterLayer);
  }
  PrintDialog printDialog = new PrintDialog();
  PrintDocument printDocument = new PrintDocument();
  printDocument.DefaultPageSettings.Landscape = true;
  if (pagePrinterLayer.Orientation == PrinterOrientation.Portrait)
  {
    printDocument.DefaultPageSettings.Landscape = false;
  }
  PrinterGeoCanvas printerGeoCanvas = new PrinterGeoCanvas();
  printerGeoCanvas.DrawingArea = printDocument.DefaultPageSettings.Bounds;
  printerGeoCanvas.BeginDrawing(printDocument, pagePrinterLayer.GetBoundingBox(), wpfMap1.MapUnit);
  // Loop through all of the PrintingLayer in the PrinterInteractiveOverlay and print all of the
  // except for the PagePrinterLayer                
  Collection<SimpleCandidate> labelsInAllLayers = new Collection<SimpleCandidate>();
  foreach (PrinterLayer printerLayer in printerInteractiveOverlay.PrinterLayers)
  {
    printerLayer.IsDrawing = true;
    if (!(printerLayer is PagePrinterLayer))
    {
      printerLayer.Draw(printerGeoCanvas, labelsInAllLayers);
    }
    printerLayer.IsDrawing = false;
  }
  printerGeoCanvas.Flush();
  wpfMap1.MapUnit = eOrigUnit;
  System.Windows.Forms.PrintPreviewDialog printPreviewDialog = new System.Windows.Forms.PrintPreviewDialog();
  printPreviewDialog.Document = printDocument;
  System.Windows.Forms.DialogResult dialogResult = printPreviewDialog.ShowDialog();
}
        
      
    
