Q:

Convert Wpf Control into pdf

I would like to convert my WPF control into pdf, do anyone helps me with some example?
I have a WPF chart and a listview:

above image is the output of my WPF, and I want to convert this page into pdf?
anyone can help me with it?below is my code which can create a pdf but inside the pdf have no content, please help.
public void SaveCurrentViewToXPS()
        {

            var dialog = new SaveFileDialog();

            dialog.AddExtension = true;
            dialog.DefaultExt = "pdf";
            dialog.Filter = "PDF Document (*.pdf)|*.pdf";

            if (dialog.ShowDialog() == false)
                return;

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

            PrintDialog printDlg = new PrintDialog();
            Size pageSize = new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight - 100);
            lw.Width = 2100;
            lw.Height = 2970;

            //Create first page of document
            fixedPage.Children.Add(lw);
            //fixedPage.Children.Add(ColumnChart2);
            ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
            fixedDoc.Pages.Add(pageContent);

            // write to PDF file
            string tempFilename = "temp.xps";
            File.Delete(tempFilename);
            XpsDocument xpsDoc = new XpsDocument(tempFilename, FileAccess.Write);
            XpsDocumentWriter xWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);
            xWriter.Write(fixedDoc.DocumentPaginator);
            xpsDoc.Close();

            PdfSharp.Xps.XpsConverter.Convert(tempFilename);
        }

Thanks

A:

Problem might be the way visuals are added in xps document.                                                                                       `  FixedDocument fixedDoc = new FixedDocument();
            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();
        PrintDialog printDlg = new PrintDialog();
        Size pageSize = new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight - 100);

        var visual = ((System.Windows.Controls.Panel)this.Content).Children[0] as UIElement;
       ((System.Windows.Controls.Panel)this.Content).Children.Remove(visual);
        fixedPage.Children.Add(visual);
        ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);

        fixedDoc.Pages.Add(pageContent);

        // write to PDF file
        string tempFilename = "temp.xps";
        File.Delete(tempFilename);
        XpsDocument xpsd = new XpsDocument(tempFilename, FileAccess.ReadWrite);
        System.Windows.Xps.XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd);
        xw.Write(fixedDoc);
        xpsd.Close();
        PdfSharp.Xps.XpsConverter.Convert(tempFilename, dialog.FileName, 1);`                                                                                refer  https://github.com/EbenZhang/PdfSharp.XPS

