在silverlight页面中的代码是:
private void button1_Click(object sender, RoutedEventArgs e)
{
//Sc.GetAllArticlByIdCompleted +=new EventHandler<GetAllArticlByIdCompletedEventArgs>(Sc_GetAllArticlByIdCompleted);
//Sc.GetAllArticlByIdAsync("1");
ServiceReference1.Service1Client Sc = new ServiceReference1.Service1Client();
Sc.GetAllArticlCompleted +=new EventHandler<GetAllArticlCompletedEventArgs>(Sc_GetAllArticlCompleted);
Sc.GetAllArticlAsync();
}
void Sc_GetAllArticlCompleted(object sender, GetAllArticlCompletedEventArgs e)
{
List<articl> art = new List<articl>();
dataGrid1.ItemsSource = art;
}
不知为何获取不到数据,dataGrid1中只显示表的列名,art.count的个数为0……谢谢
回调函数写错了啊...
List<articl> art = new List<articl>();
dataGrid1.ItemsSource = art;
代码的意思只是仅仅初始化一个List<>而已,你要把数据加进来呀。
比如这样的 foreach(var item in e.Result)
art.Add(item);
这样才可以的