You might consider using RenderTargetBitmap to save it to file. See
How to Render Bitmap or to Print a Visual in WPF[
^]
Or you could leverage some of the XamlReader options
public static UserControl RenderUserControlFromString(string rawXamlString,
object dataContextObject = null)
{
var document = XamlReader.Load(new XmlTextReader(new StringReader(rawXamlString))) as UserControl;
if (dataContextObject != null)
{
document.DataContext = dataContextObject;
}
return document;
}
public static UserControl RenderUserControlFromFile(string templatePath,
object dataContextObject = null)
{
string rawXamlText = string.Empty;
using (StreamReader streamReader = File.OpenText(templatePath))
{
rawXamlText = streamReader.ReadToEnd();
}
return RenderUserControlFromString(rawXamlText, dataContextObject);
}
The above code is based on the series of articles starting with
http://roecode.wordpress.com/2007/12/21/using-flowdocument-xaml-to-print-xps-documents/[
^]
I'm using an ItemsControl with Canvas much as you are; I load the user control into memory and plop it into a document for viewing or printing.