private static BitmapSource CreateDiagramImage(RadDiagram diagram, Rect enclosingBounds, Size returnImageSize, Brush backgroundBrush, Thickness margin, double dpi) { var virtualizationService = diagram.ServiceLocator.GetService <IVirtualizationService>() as VirtualizationService; virtualizationService.ForceRealization(); diagram.UpdateLayout(); var itemsHost = diagram.FindChildByType <DiagramSurface>(); BitmapSource image = CreateWriteableBitmap(itemsHost, enclosingBounds, returnImageSize, backgroundBrush, margin, dpi); virtualizationService.Virtualize(); diagram.UpdateLayout(); return(image); }