Skip to main content
Home Forums Silverlight Programming Programming with .NET - General How to call wcf service from silverlight class library to get result and call that class function from xaml page
2 replies. Latest Post by mahendra.gurav on December 24, 2008.
(0)
mahendra...
Member
136 points
158 Posts
12-24-2008 12:54 AM |
Hi,
Previously i call wcf serive directly from XAML page. wcf return list and i show it in datagrid in xaml page.It works fine.
Now i want to do different. I dont want to call wcf service directly from XAML page. Instead of this I take one Silverlight class liabrary in the same solutiona and service referesnce in that class liabrary. From the class liabrary i want to call the wcf service and in the Xaml want to call that class to get result.
My code is as below
page.Xaml code
cls.getList();
dgResult.ItemsSource = cls.objCollection;
SilverlightClass Library code
{
sc.GetCompListAsync();
}
objCollection = e.Result;
But objCollection returns zero in XAMl. I think its due to async call.
So please give solution. Also tell is it right way to do this. Here i want to create midddle tier to call wcf service. Dont want to call wcf service directly from XAML page.
Thanks,
Mahendra
Ken Tucker
All-Star
16276 points
2,479 Posts
12-24-2008 5:02 AM |
The code will never work as you have done it. You would have to have some way to notify the user the data is back. Maybe you could raise an event when the data is returned
12-24-2008 5:18 AM |
Thnaks for replying. Please give any sample related to this.