private BitmapImage GetImageSource() { MemoryStream streamSource = null; if (PreviewWidth != 0 && PreviewHeight != 0 && Width != 0 && Height != 0 && LegendItems.Count > 0) { Bitmap nativeImage = new Bitmap(PreviewWidth, PreviewHeight); PlatformGeoCanvas geoCanvas = new PlatformGeoCanvas { CompositingQuality = CompositingQuality.HighSpeed, SmoothingMode = SmoothingMode.HighSpeed, DrawingQuality = DrawingQuality.CanvasSettings, }; LegendAdornmentLayer tmpLegendAdornmentLayer = ToLegendAdornmentLayer(); double left = -tmpLegendAdornmentLayer.Width * .5; double top = tmpLegendAdornmentLayer.Height * .5; double right = left + tmpLegendAdornmentLayer.Width; double bottom = top - tmpLegendAdornmentLayer.Height; geoCanvas.BeginDrawing(nativeImage, new RectangleShape(left, top, right, bottom), GeographyUnit.Meter); simpleCandidates.Clear(); tmpLegendAdornmentLayer.Draw(geoCanvas, simpleCandidates); geoCanvas.EndDrawing(); streamSource = new MemoryStream(); nativeImage.Save(streamSource, ImageFormat.Png); } BitmapImage previewSource = new BitmapImage(); if (streamSource != null) { previewSource.BeginInit(); previewSource.StreamSource = streamSource; previewSource.EndInit(); previewSource.Freeze(); } return(previewSource); }