I tried to get the XPS view of a ListBox following what is mentioned in this answer:
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
ListBox lbx = new ListBox();
lbx.DataContext = lb.DataContext;
fixedPage.Children.Add(lbx);
pageContent.Child = fixedPage;
fixedDoc.Pages.Add(pageContent);
//Create any other required pages here
docv.Document = fixedDoc;
lb is the ListBox shown in the top half of the image while the XPS view is below. However, it is empty except for the small square at the beginning. What am I doing wrong and how do I get the listbox to be shown in the XPS view.