Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Get started with Async web service programming

$
0
0

I have a web service that works with a website. I would like to create an application that is gong to connect to this web service and return some data. I have been following a few tutorials and have the following code:

Public Class ItemViewModel    Implements INotifyPropertyChanged    Private _Name As String    Public Property Name() As String        Get            Return _Name        End Get        Set(ByVal value As String)            If Not value.Equals(_Name) Then                _Name = value                NotifyPropertyChanged("Name")            End If        End Set    End Property

..... along with other properties resembling the table from my database.

I then have a MainViewModel

    Private _Customer As New CustomerService.Customer   

Public Sub LoadData()        Dim myService As New CustomerService.CustomerClient        myService.GetCustomerByNameAsync("Andy")        AddHandler myService.GetCustomerByNameCompleted, AddressOf CustomerByName        Items.Add(NewItemViewModel With {.Name = .Customer.Name})

End Sub

    Private Sub CustomerByName(sender As Object, e As CustomerService.GetCustomerByNameCompletedEventArgs)        .Customer = e.Result    End Sub

The problem i have is the service returns data when i check with WCF test but on this occasion when running the app i keep getting an empty object for .Customer. I have tried making it into a shared variable but nothing seems to hold the data i get from the service.

Could anyone give me a hand with this to see how i could hold the data in my MainViewModel and then i would like to bind it with a textblock text property?

Thanks


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>