我有一个Silverlight应用程序,它使用Web服务来创建XPS文档。文档模板是作为WCF类库中的XAML控件创建的。用WCF类库中的图像生成XPS文档的问题
public void GenerateXPS()
{
Type typeofControl = Type.GetType(DOCUMENT_GENERATOR_NAMESPACE + "." + ControlTypeName, true);
FrameworkElement control = (FrameworkElement)(Activator.CreateInstance(typeofControl));
control.DataContext = DataContext;
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
//Create first page of document
fixedPage.Children.Add(control);
((IAddChild)pageContent).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
XpsDocument xpsd = new XpsDocument(OutputFilePath + "\\" + OutputFileName, FileAccess.ReadWrite);
System.Windows.Xps.XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd);
xw.Write(fixedDoc);
xpsd.Close();
SaveToDocumentRepository();
}
为了将实际数据绑定到我的文档模板,我设置了控件的DataContext属性。问题是,当我看着我的XPS时,图像(我将图像控件的源代码绑定到表示图像URL的字符串属性)不会显示为未加载。我怎么解决这个问题?谢谢!
该URL是否有效?如果您尝试在浏览器中打开它,它会显示吗? –
是的URL是有效的 –