将IList绑定到ListBox [英] Binding an IList to a ListBox

查看:69
本文介绍了将IList绑定到ListBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧我在一个简单的Silverlight控件上有一个Listbox。我进行WCF服务调用以获取填充了Entity框架类的IList。


代码:



 





//加载结果







 



IList < tbl_Manufacturer


> manufacturerList = e.Result;


 


lstCustomers.ItemsSource = manufacturerList ;



运行时确实在IList中取回了正确的结果(用for循环验证),但是当设置绑定时,我在页面上得到的值是"< Classname> .tbl_Manufacturer"它不会从IList加载值。


我相信
这是一个完全没有问题的问题,但任何人都知道我错过了什么。我的Google / Bing kung foo现在让我失望。


 





解决方案

您必须定义ItemTemplate,请查看以下链接:


http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-5-using-the-listbox-and-databinding-to-display-list-data.aspx


Alright I got a Listbox on a simple Silverlight control. I makes a WCF service call to grab an IList filled with an Entity framework class.

Code:

 

//load results

 

IList<tbl_Manufacturer

> manufacturerList = e.Result;

 

lstCustomers.ItemsSource = manufacturerList;

When this runs it does pull back the proper results in the IList (verified with a for loop), but when the binding is set all I get on the page is the value "<Classname>.tbl_Manufacturer" It does not load the values from the IList.

I am sure this a completely noob question but anyone know what I am missing. My Google/Bing kung foo is failing me right now.

 

解决方案

You have to define the ItemTemplate, check out the below link:

http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-5-using-the-listbox-and-databinding-to-display-list-data.aspx


这篇关于将IList绑定到ListBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆