简体   繁体   English

如何在应用程序启动时将一个特定的 xps 文档加载到 DocumentViewer 中进行阅读而不加载它

[英]how to load one specific xps document into DocumentViewer for reading without loading it when application start

I only made a button to add a document.我只做了一个按钮来添加一个文档。 Is it possible to somehow load a document from a folder with a Visual Studio project or something else?是否可以以某种方式从具有 Visual Studio 项目或其他内容的文件夹中加载文档?

private void Load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "XPS file (*.xps)|*.xps";

            if (ofd.ShowDialog() == true)
            {
                XpsDocument doc = new XpsDocument(ofd.FileName, FileAccess.Read);
                documentViewer.Document = doc.GetFixedDocumentSequence();
            }
        }
private void Book1_Click(object sender, RoutedEventArgs e)
        {
            var xpsDocument = new XpsDocument(@"C:documentPath", FileAccess.Read);
            documentViewer.Document = xpsDocument.GetFixedDocumentSequence();
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM