Custom listboxa item ekleyemiyorum
22.12.2013 - 05:10
Merhaba, elimde örnek bir proje var.Projede custom bir listeden lisboxa itemler ekleniyor.
SimpleItems = new List<SampleData>() { new SampleData(){Name = "User1:", ImagePath="/Images/user.png", Group ="wiki"}, new SampleData(){Name = "User2:", ImagePath="/Images/user.png", Group="froum"}, new SampleData(){Name = "User3:", ImagePath="/Images/user.png", Group ="nokia"}, new SampleData(){Name = "User4:", ImagePath="/Images/user.png", Group ="dig"}, new SampleData(){Name = "User5:", ImagePath="/Images/user.png", Group ="mirosoft"}, new SampleData(){Name = "User6:", ImagePath="/Images/user.png", Group ="facebook"}, new SampleData(){Name = "User7:", ImagePath="/Images/user.png", Group ="wiki"}, new SampleData(){Name = "User8:", ImagePath="/Images/user.png", Group="froum"}, new SampleData(){Name = "User9:", ImagePath="/Images/user.png", Group ="nokia"}, new SampleData(){Name = "User10:", ImagePath="/Images/user.png", Group ="dig"}, new SampleData(){Name = "User11:", ImagePath="/Images/user.png", Group ="mirosoft"}, new SampleData(){Name = "User12:", ImagePath="/Images/user.png", Group ="facebook"}, new SampleData(){Name = "User13:", ImagePath="/Images/user.png", Group ="wiki"}, new SampleData(){Name = "User14:", ImagePath="/Images/user.png", Group="froum"}, new SampleData(){Name = "User15:", ImagePath="/Images/user.png", Group ="nokia"}, new SampleData(){Name = "User16:", ImagePath="/Images/user.png", Group ="dig"}, new SampleData(){Name = "User17:", ImagePath="/Images/user.png", Group ="mirosoft"}, new SampleData(){Name = "User18:", ImagePath="/Images/user.png", Group ="facebook"}, new SampleData(){Name = "User19:", ImagePath="/Images/user.png", Group ="wiki"}, new SampleData(){Name = "User20:", ImagePath="/Images/user.png", Group="froum"}, new SampleData(){Name = "User21:", ImagePath="/Images/user.png", Group ="nokia"}, new SampleData(){Name = "User22:", ImagePath="/Images/user.png", Group ="dig"}, new SampleData(){Name = "User23:", ImagePath="/Images/user.png", Group ="mirosoft"}, new SampleData(){Name = "User24:", ImagePath="/Images/user.png", Group ="facebook"}, new SampleData(){Name = "User25:", ImagePath="/Images/user.png", Group ="twitter"} }; Ancak ben bunu dinamik olarak yapmak istiyorum. Örneğin kullanıcı bir butona bastığında; string[] user = new string[1000]; string[] group = new string[1000]; for (int i = 0; i < 1000; i++) { user[i] = "user " + i.ToString(); group[i] = "group " + i.ToString(); SimpleItems.Add(new SampleData() {Name = user[i], ImagePath = "/Images/user.png", Group = group[i]}); } Ancak SimpleItems listesine eklemeye çalıştığında NullReferenceException hatası veriyor. Bu durumu nasıl çözebilirim acaba?
13
Görüntülenme
0 Beğeni