0
我有follwing类XAML绑定到对象
public class Noticia
{
public string texto { get; set; }
public string titulo { get; set; }
public int id { get; set; }
public Imagem img { get; set; }
}
包含该类型IMAGEM的属性
public class Imagem
{
public string path { get; set; }
public string page { get; set; }
public int id { get; set; }
}
我再有另一个类创建一流
的项目清单public class NoticiasDB
{
public List<Noticia> listaNoticias { get; set; }
public NoticiasDB()
{
Noticia not1 = new Noticia() { titulo = "Noticia 1", texto = "lalala", id = 1 };
Noticia not2 = new Noticia() { titulo = "Noticia 1", texto = "lalala.", id = 2 };
Noticia not3 = new Noticia() { titulo = "Noticia 1", texto = "lalala.", id = 3 };
Noticia not4 = new Noticia() { titulo = "Noticia 1", texto = "lalala", id = 4 };
Noticia not5 = new Noticia() { titulo = "Noticia 1", texto = "lalala.", id = 5 };
not1.img = new Imagem() { path = "Assets/pipa.png", page = "Noticias", id = 1 };
not2.img = new Imagem() { path = "Assets/midia.png", page = "Noticias", id = 2 };
not3.img = new Imagem() { path = "Assets/pipa.png", page = "Noticias", id = 3 };
not4.img = new Imagem() { path = "Assets/midia.png", page = "Noticias", id = 4 };
not5.img = new Imagem() { path = "Assets/pipa.png", page = "Noticias", id = 5 };
listaNoticias = new List<Noticia>();
listaNoticias.Add(not1);
listaNoticias.Add(not2);
listaNoticias.Add(not3);
listaNoticias.Add(not4);
listaNoticias.Add(not5);
}
}
所以我的问题是我如何做一个元素的绑定,可以从m中获取图像中的路径项目
Y的名单我想这样的事情,但
<Image Name="NewsImg" Source="{Binding img.path}" Stretch="Fill" Grid.Column="0"/>