Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Problem consuming a WCF service + Silverlight 4

Problem consuming a WCF service + Silverlight 4

Scheduled Pinned Locked Moved WPF
helpcsharpdatabasewcfquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CrafterIt
    wrote on last edited by
    #1

    Hello im new to Silverlight and i'm having a problem with consuming a WCF service. i have created a Currentname.cs that i use for databinding. And news.cs where i store the data The problem is when i call the service the it doesn't trigger the "event" and populate the propery Could anyone help? private ObservableCollection<News> _PrivateNews; public ObservableCollection<News> _News { get { if (_PrivateNews.Count == 0) { getData(); } return _PrivateNews; } set { _PrivateNews = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("News")); } } public void getData() { ServiceReference1.Service1Client newservice = new ServiceReference1.Service1Client(); newservice.GetNewsCompleted += new EventHandler<ServiceReference1.GetNewsCompletedEventArgs>(newservice_GetNewsCompleted); newservice.GetNewsAsync(); } void newservice_GetNewsCompleted(object sender, ServiceReference1.GetNewsCompletedEventArgs e) { ObservableCollection myNews = new ObservableCollection(); foreach (ServiceReference1.P_GetSomeNewsResult x in e.Result) { News n = new News(); n.Header = x.NewsHeader; n.Content = x.News; myNews.Add(n); } _News = myNews; }

    modified on Friday, October 22, 2010 8:56 AM

    S 1 Reply Last reply
    0
    • C CrafterIt

      Hello im new to Silverlight and i'm having a problem with consuming a WCF service. i have created a Currentname.cs that i use for databinding. And news.cs where i store the data The problem is when i call the service the it doesn't trigger the "event" and populate the propery Could anyone help? private ObservableCollection<News> _PrivateNews; public ObservableCollection<News> _News { get { if (_PrivateNews.Count == 0) { getData(); } return _PrivateNews; } set { _PrivateNews = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("News")); } } public void getData() { ServiceReference1.Service1Client newservice = new ServiceReference1.Service1Client(); newservice.GetNewsCompleted += new EventHandler<ServiceReference1.GetNewsCompletedEventArgs>(newservice_GetNewsCompleted); newservice.GetNewsAsync(); } void newservice_GetNewsCompleted(object sender, ServiceReference1.GetNewsCompletedEventArgs e) { ObservableCollection myNews = new ObservableCollection(); foreach (ServiceReference1.P_GetSomeNewsResult x in e.Result) { News n = new News(); n.Header = x.NewsHeader; n.Content = x.News; myNews.Add(n); } _News = myNews; }

      modified on Friday, October 22, 2010 8:56 AM

      S Offline
      S Offline
      SledgeHammer01
      wrote on last edited by
      #2

      Looks like you are firing a property change for "News", but your property is called "_News".

      C 1 Reply Last reply
      0
      • S SledgeHammer01

        Looks like you are firing a property change for "News", but your property is called "_News".

        C Offline
        C Offline
        CrafterIt
        wrote on last edited by
        #3

        Thanks, the binding works great now :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups