WP7 - List Update

I finally got to the Windows startup phone. I'm not very good yet, but I hope you guys understand what I want to do here.

From what I learned from other programmers, the ObservableCollection can be updated in real time while it is attached to an object, such as a list. All changes to the ObservableCollection will cause the user interface of the object that it is bound to update to update it.

So what I'm trying to do is download the file from my server, parse it using json, and then update the ObservableCollection with the new data. However, the web client does not seem to download new data until the application is open!


Here is a gif showing how the application is currently running: enter image description here

And here is my code (cut a bit):

Dim aList As New ObservableCollection(Of classes.consoles)

Private Sub PhoneApplicationPage_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        checkforconsoles()
End Sub

Public Sub checkforconsoles()
        Dim wc As New WebClient()
        AddHandler wc.DownloadStringCompleted, AddressOf downloaded
        wc.DownloadStringAsync(New Uri("http://localhost/api/?function=GetConsolesForUser&userid=" & id))
    End Sub

    Private Sub downloaded(sender As Object, e As DownloadStringCompletedEventArgs)

        aList.Clear()
        'MessageBox.Show(e.Result)

        Dim o As JObject = JObject.Parse(e.Result)

        Dim jarray As JArray = DirectCast(o("results"), JArray)

        Try
            Dim i As Integer = jarray.Count()

            For i = 0 To jarray.Count() - 1 Step 1

                Dim id As String = jarray(i)("id").ToString
                Dim name As String = jarray(i)("name").ToString
                Dim image As String = jarray(i)("image").ToString

                MessageBox.Show(name)

                Dim c As classes.consoles = New classes.consoles()
                c.categoryimage = New Uri(image)
                c.categoryname = name
                c.categoryid = id

                aList.Add(c)
            Next

            listBoxview.ItemsSource = aList
            StackPanel1.Visibility = Windows.Visibility.Collapsed
            StackPanel2.Visibility = Windows.Visibility.Visible

        Catch ex As Exception
            StackPanel2.Visibility = Windows.Visibility.Collapsed
            StackPanel1.Visibility = Windows.Visibility.Visible
        End Try

    End Sub

Private Sub ApplicationBarIconButton_Click_1(sender As System.Object, e As System.EventArgs)
    checkforconsoles()
End Sub

- , ?: (

.

+3
1

cachine WebClient. , , URL- , WebClient . - GUID, GUID .

wc.DownloadStringAsync(New Uri("http://localhost/api/?function=GetConsolesForUser&
                         userid=" & id & "&random=" + Guid.NewGuid().ToString()))
+2

All Articles