tags:

views:

33

answers:

0

Here's the bottom line: I'm trying to avoid using RDLC/SSRS and instead create XPS files from my XAML.

I've combined pieces of code from various articles here and I am (1) cloning the XAML objects I need from my page and (2) passing those to a new page in an XPS object

This process seems to work just fine with non data-bound objects that I can still modify with code. Here is a quick example, showing how I'm cloning an existing label:

pgeIncidentReport newPage = new pgeIncidentReport();

string Xaml = XamlWriter.Save(newPage.lblHeader);
StringReader stringReader = new StringReader(Xaml);
XmlReader xmlReader = XmlReader.Create(stringReader);
System.Windows.Controls.Label newL = System.Windows.Controls.Label)XamlReader.Load(xmlReader);

FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();

//Create first page of document
fixedPage.Children.Add(newL);

However, when I apply the same code to objects that contain a DataContext, it does not render the content. It will render the object itself, like it might show the outline of a listbox or one empty column of a datagrid, but it will not show any of the other data. I have confirmed that the page I'm pulling objects from renders propely, it is only in the cloning and the XPS rendering that the object data is lost.

Help.