Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
450
How can i refresh the xamgrid??
posted

Hello,

i´m trying to refresh a xamgrid dynamically but i can´t.

I have a object wich it is a list of objects and i visualize it with xamgrid.itemSource.

Then i modify or add an object and want to see the new xamgrid.

I tried with xamgrid.itemSource=the modify list but it doesn´t work.

this is my code.

 

Sub entityHandler(EntityObj As Object)

        Try

            If (EntityObj Is Nothing) Then

                MessageBox.Show("No tiene datos cambiados")

            Else

                MessageBox.Show("Tiene datos cambiados")

                Dim valuePropertyId As Object = EntityObj.GetType().GetProperty(Me.myEntityList.CampoId).GetValue(EntityObj, Nothing)

                'here i add a entity to the list of entities

                If valuePropertyId = 0 Then

                    Me.myEntityList.Entities.Add(EntityObj)

                Else

                'here i search and modify an object

                    For i As Integer = 0 To Me.myEntityList.Entities.Count - 1


                        Dim valueProperty As Object = Me.myEntityList.Entities(i).GetType().GetProperty(Me.myEntityList.CampoId).GetValue(Me.myEntityList.Entities(i), Nothing)


                        If (valueProperty.Equals(valuePropertyId)) Then

                            Me.myEntityList.Entities(i) = EntityObj

                            'here i try to visualize the new list

                            Me.dataGrid.ItemsSource = Me.myEntityList.Entities

                            Exit For

                        Else


                        End If


                    Next


                End If

                'here i try to visualize the new list with the object add

                Me.dataGrid.ItemsSource = Me.myEntityList.Entities


            End If

        Catch ex As Exception

            MessageBox.Show("EntityHandler Error" & ex.Message)

        End Try

     End Sub

 

I tried to make a function 

    Me.LayoutRoot.Children.Clear()

    Me.LayoutRoot.Children.Add(te)

but it doesn´t work because i´m working with a user control and is inside another controls. And it´s going to be use recursively.

 

Thank you for your support.

Sincerely

David A 

Parents Reply
  • 138253
    Offline posted in reply to David

    Hello David,

    I have been looking into your project and I changed the types of your collection Properties in the EntityList class from List to ObservableCollection, because the List class doesn’t implement the INotifyCollectionChanged interface and the XamGrid cannot be notified when the collection changes.

    Hope this helps you.

Children