Click here to Skip to main content
13,045,285 members (57,072 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All

I developed the wcf rest service and i consumed in windows phone7.1
but my listbox was empty.
public List<Product> GetProducts()
            PractiseEntities db = new PractiseEntities();
            var students = from p in db.StudentEntities select p;
            List<Product> st1 = students.ToList().ConvertAll(new Converter<StudentEntity, Product>(TranslateStudentEntityToStudent1));
            return st1;

private Product TranslateStudentEntityToStudent1(StudentEntity student)
            Product p = new Product();
            p.ProductID = student.ID;
            p.ProductName = student.Name;
            p.QuantityPerUnit = student.Adress;
            p.UnitPrice = student.DOB;
            return p;

Windows Phone7.1 app:
private void btn_getdata_Click(object sender, RoutedEventArgs e)
            WebClient proxy1 = new WebClient();
            proxy1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(proxy1_DownloadStringCompleted);
            proxy1.DownloadStringAsync(new Uri("http://localhost:49166/RestService.svc/Student"));
  private void proxy1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
Stream s = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
            DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(List<Student>));
            List<Student> result = obj.ReadObject(s) as List<Student>;
            listBox2.ItemsSource = result;

ListBox Height="172" Foreground="White" FontSize="25" HorizontalAlignment="Left" Margin="20,31,0,0" Name="listBox2" VerticalAlignment="Top" Width="401" >
  <TextBlock Text="{Binding Adress}" FontSize="25"/>
Posted 20-Mar-13 22:05pm
Updated 20-Mar-13 22:22pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100