1
需要Silverlight for Windows Phone的ListBox DataBindg幫助。代碼如下:如何在Silverlight for Windows Phone7中綁定ListBox的數據列表
1)在頁面加載事件:
注:圖片是圖片的收集,PicNames是圖片的名稱的集合。
var ml = new MediaLibrary();
var ChkPics = ml.Pictures;
var PicNames = from p in ChkPics
where p.Name.Contains("s")
select p;
2)靜態類
public static class PhotoNames
{
private static List<string> m_Photoname = new List<string>();
public static List<string> PhotoFileNames
{
get
{
return m_Photoname;
}
set
{
m_Photoname = value;
}
}
}
讓所有的照片文件名中PicNames以這種方式後:
在頁面加載事件:
var ml = new MediaLibrary();
var ChkPics = ml.Pictures;
var PicNames = from p in ChkPics
where p.Name.Contains("s")
select p;
foreach (var pic in PicNames)
{
PhotoNames.PhotoFileNames.Add(pic.Name);
}
我如何將一個ListBox綁定到這個靜態類並在ListBox中顯示TextBlock
中的所有數據?
謝謝。
它部分作爲無圖片顯示。基於此var ml = new MediaLibrary(); (圖片=> picture.Name.Contains(「s」)); – MilkBottle 2010-10-11 09:18:02
圖片未顯示。基於Where語句。我對XAML進行了更改:圖片到圖片或圖片。 – MilkBottle 2010-10-11 09:20:32
未顯示圖片。基於Where語句。我對XAML進行了更改:圖片到圖片或圖片。 – MilkBottle 2010-10-11 09:20:34