public static XGraphics CreateMeasureContext(XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection) { XGraphics gfx = null; #if GDI gfx = new XGraphics(Graphics.FromImage(new Bitmap(100, 100)), size, pageUnit, pageDirection); #endif #if WPF && !SILVERLIGHT gfx = new XGraphics((System.Windows.Media.DrawingContext)null, size, pageUnit, pageDirection); #endif #if SILVERLIGHT gfx = new XGraphics(new Canvas(), size, pageUnit, pageDirection); #endif return gfx; }