我想使用webservice显示来自远程数据库的药物列表 输出如下所示
md1
md2
md2...etc
为此我写了下面的客户端,但它不工作,错误来了。 请帮我开发windows phone app
public partial class Antocids : PhoneApplicationPage
{
ObservableCollection<Class1> p = new ObservableCollection<Class1>();
public Antocids()
{
InitializeComponent();
listBox1.DataContext = p;
ServiceReference3.ProductsClient client = new ServiceReference3.ProductsClient();
client.getProdDetailsCompleted += new EventHandler<ServiceReference3.getProdDetailsCompletedEventArgs>(client_getProdDetailsCompleted);
client.getProdDetailsAsync();
}
private void client_getProdDetailsCompleted(object sender, ServiceReference3.getProdDetailsCompletedEventArgs e)
{
p.Clear(); // assuming you want to clear the data each time you get a new result
foreach (var result in e.Result)
p.Add(result); // here i got the error the error is invalid arguments are passed to overloaded method add()
}
}
答案 0 :(得分:0)
试试这个p.Add((Class1)result);