I’ve got a solution with a WPF client, a WCF service and a Silverlight Client (SL 4).
The WPF client works smoothly but the Silverlight is acting up on a point which I’m not sure how to handle it.
These are snippets of the code I have in Silverlight:
using sl_HFClient.svc;
namespace sl_HFClient
{
public partial class MainPage : UserControl
{
svc.IhfsvcClient dataSrv = new svc.IhfsvcClient();
ObservableCollection<svc.ReasonData> reasonData;
}
This is to set everything up, next comes the call to the service:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
dataSrv.wcGetReasonsCompleted += ReasonsLoaded;
dataSrv.wcGetReasonsAsync();
}
And at last, the code to get the collection and bind it to a combobox:
private void ReasonsLoaded(object sender, wcGetReasonsCompletedEventArgs e)
{
reasonData = e.Result;
}
However, this returns the following error:
Cannot implicitly convert type ‘sl_HFClient.svc.ReasonData[]’ to ‘System.Collections.ObjectModel.ObservableCollection’
I’m quite new to Silverlight and C#, I’ve done some things with SL4 and VB.NET before and
by comparing this code with a VB.NET project it seems to work.
What am I doing wrong??
//JaggenSWE
Try the following:
Not entirely sure if this will work in Silverlight, but the solution nonetheless is to explicitly create a new
ObservableCollection<ReasonData>instead of trying to implicitly cast from anReasonData[].