2011-08-04 61 views
0

如何在圖像中讀取&當我的輸出爲以下內容時,將它們顯示在我的Silverlight 2.0控件上? (我目前使用lists.asmx)從SharePoint 2007自定義列表和顯示@ Silverlight 2.0控件中讀入圖像,

20; #http://苔:48420 /圖像選取器圖片 列表/ 1e166fc4-A07A-4680-a52a-c04f75394cc9.jpg; #http://苔蘚:48420 /圖像%20Picker%20Picture%20List/_t/1e166fc4-A07A-4680-a52a-c04f75394cc9_jpg.jpg

我的Silverlight應用程序是類似於:http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-5-using-the-listbox-and-databinding-to-display-list-data.aspx

段:

private void ProcessResponse2() 
     { 
      XDocument results = XDocument.Parse(_responseString); 

      _StaffNews = (from item in results.Descendants(XName.Get("row", "#RowsetSchema")) 

          //where !item.Element("NewsThumbnail").Attribute("src").Value.EndsWith(".gif") 
          select new StaffNews() 
          { 
           Title = item.Attribute("ows_Title").Value, 
           NewsBody = item.Attribute("ows_NewsBody").Value, 
           Thumbnail = FormatImageUrl2(item.Attribute("ows_NewsThumbnail").Value), 
           DatePublished = item.Attribute("ows_Date_Published").Value, 
           PublishedBy = item.Attribute("ows_PublishedBy").Value, 
          }).ToList(); 

      this.NewsList.DataContext = _StaffNews;    
     } 

private string FormatImageUrl2(string value) 
     { 
      return value.Substring(0, value.IndexOf(',')); 
     } 

回答

0

原來,我必須編輯方法'FormatImageUrl2'內的行:

返回value.Substring(value.LastIndexOf(「;#」)+ 2);

相關問題