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)
'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
End If
Next
'here i try to visualize the new list with the object add
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
Hello David,
Thank you for your post. I have been looking into it, but it seems like I am missing something about your scenario, so could you please send me an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward for your reply.
the problem is when i add an object.
The function that i made works for modify but not for add.
Anyway i think is not a good solution.
Thank you for your support,
Sincerelly
David A.
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.
Hello Stephan,
Thank you so much for your support, i think i will not be able to figure it out. Your advice really helps me.
It works great for add.
But i´m still having problems with the modify issue.
The function
Private Sub dataGrid_DataObjectRequested(sender As System.Object, e As Infragistics.Controls.Grids.DataObjectCreationEventArgs)
has Infragistics.Controls.Grids.DataObjectCreationEventArgs and it works for add but not for modify.
I´m looking a parameter for modify, something like "DataObjectModifyEventArgs" or something like that but i´m having no luck.
Thank you for all the support, you are doing a great job.
Sincerelly.
Sorry Stefan, I misspelled your name.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Hello Stefan,
I have not yet succeeded. I think it´s because the xamgrid has no binding.
Right now we are changing our architecture to mvvm and implementing RIA Services.
And after that i will return with the xamgrid.
I will keep you informed of the progress.
Thank you Stefan for your concern.
Sincerely.