加载 FlowDocument.xaml 这是我的解决方案的一部分
我在当前的 WPF 项目中创建了 FlowDocument.xaml。我想要做的是,当用户单击按钮时,XAML 文档将加载到后面的代码中,修改文档上的一些数据,然后将其打印出来。症结在于我不知道如何加载流程文档以便我可以修改它。
当我这样做时:
FileStream fs = File.Open("FlowDocument.xaml", FileMode.Open)
它说找不到该文件。该文件是项目的一部分,我猜它在编译时会与项目的其余部分打包在一起。
任何帮助表示赞赏
I created a FlowDocument.xaml in my current WPF project. What i want to do is when the user clicks a button the XAML document will be loaded in the code behind, have some data on the document modified, and then print it out. The sticking point is i don't know how load the flow document so that i can modify it.
When I do:
FileStream fs = File.Open("FlowDocument.xaml", FileMode.Open)
It says that it can't find the file. The file is part of the project and I'm guessing it gets packaged with the rest of the project when compiled.
Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设它被配置为一个资源,那么你可以像这样加载它:
Assuming it is configured to be a Resource, then you can load it like so:
这看起来可能是路径/相对路径问题...仅出于测试目的,尝试在 File.Open 语句中指定整个物理/绝对路径...
您还可以
检查当前目录是什么然后确保文件 FlowDocument.xaml 位于该目录中
This looks like it might be a path/relative path issue...just for testing purposes, try specifying the entire physical/absolute path in the File.Open statement...
You could also do
to check to see what the current directory is and then make sure that the file FlowDocument.xaml is in that directory