我有一個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是有效的 –