我正在开发Windows Phone 7,我需要向ListBox添加图片。
我想用C#代码实现,而不是XAML。
我查阅了相关资料,但是每个人都使用BitmapImage,但是我在Windows Phone 7上无法使其正常工作。
以下是我的XAML代码:
<StackPanel Margin="0,0,0,17">
<local:MatchDates Adress="http://soccernet.espn.go.com/results/_/league/esp.1/spanish-la-liga?cc=57393" />
</StackPanel>
在我的MatchDates类中,还有一个C#函数:
void add_items(List<List<string>> code)
{
if (code.Count == 0)
this.Items.Add("no mathes");
else
{
foreach (List<string> temp1 in code)
{
foreach (string temp2 in temp1)
{
this.Items.Add(temp2);
}
this.Items.Add("---------------------------------");
}
}
}
如何在add_items函数中添加图片?
下面是代码:
Uri uri = new Uri("/eng.png", UriKind.Relative);
BitmapImage bitmap = new BitmapImage(uri);
Image img = new Image();
img.Height = 30;
img.Width = 30;
img.Source = bitmap;
this.Items.Add(img);
this.Items.Add(temp2);
只有空白区域,如何向ListBox添加图片?