/// <summary> /// Sets the render function. /// </summary> public void SetRenderFunction(Action <XGraphics> renderFunction) { if (canvas.Children.Count > 0) { canvas.Children.Clear(); } XGraphics gfx = XGraphics.FromCanvas(canvas, new XSize(100, 100), XGraphicsUnit.Presentation); renderFunction(gfx); gfx.Dispose(); // necessary in WPF }