I just study the sliverlight .
I create three project.
the one sliverlight web project
and the other is sliverlight project ,
the last is wcf project.
I think the case is easy,but I am wrong.
so I write the blog to note myself.
1) because the wcf project and sliverlight project is different domain,so when the sliverlight web project call wcf service that throw the error:" cross-domain error" . I search the message about this error with google, I found that because the two project are diffenert domain, you must add xml file "crossdomain.xml" , the file contend is
crossdomain.xml
</cross-domain-policy>
clientaccesspolicy.xml
2) sliverlight datagrid bind
//Binding b = new Binding();
//b.Path = new PropertyPath("Name");
//b.Mode = BindingMode.OneTime;
//b.Source = r;
//MyTextBlock.DataContext = r;
//MyTextBlock.SetBinding(TextBlock.TextProperty, b);
////r.Name = "echo";
////MyTextBlock2.DataContext = r;
//List<Resource> Resources = new List<Resource>();
//Resources.Add(new Resource {Name="candu",Value ="1" });
//Resources.Add(new Resource { Name = "echo", Value = "2" });
//list1.ItemsSource = Resources;
//Uri endpoint = new Uri("http://localhost:3917/handler/ResoureHandler.ashx");
//WebRequest request = WebRequest.Create(endpoint);
//request.Method = "POST";
//request.ContentType = "application/x-www-form-urlencoded";
//request.BeginGetResponse(new AsyncCallback(ResponseReady), request);
Binding binding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress(
"http://localhost:4545/Service1.svc");
ServiceReference1.ResourceListPageServiceClient client = new ServiceReference1.ResourceListPageServiceClient(binding, endPoint);
client.GetDataCompleted += new EventHandler<ServiceReference1.GetDataCompletedEventArgs>(client_GetPostsCompleted);
client.GetDataAsync();
}
void client_GetPostsCompleted(object sender, ServiceReference1.GetDataCompletedEventArgs e)
{
if (e.Error == null)
{
DG_Resource.ItemsSource = e.Result;
}
}