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
4040
XamGrid : not updated when binded data changed
posted

Hi,

We are using a Xamgrid binded to a list of objects from ViewModel.
When a property of one of the objects is updated, the Xamgrid is not reflected the changes.

We already tried to use InvalidateData().
This works as data are updated in the Xamgrid, but it as side effects.

In one of the column, we have an unbound column with a button.
Text of the button is changing when user click on it.
When InvalidateData() is called several times (each time data has been modified), buttons are not displayed
correctly as their position (or just text display) change.

In attachment, you will find a solution showing the problem.
Each 3 seconds, the lastname of second person in the Xamgrid is updated.
So 2 scenarios :
   - Whithout InvalidateData() [line 58 in code-behind] : nothing change in the grid => not as expected
   - Whith InvalidateData() : date are updated in the grid (good). Then if you click on button of 1rst line, its text change as expected but after 3 seconds, the text is swapping between  1rst and 3rd line => not really as expected.


Now 2 questions :
    1 - Is there a way in our situation to have grid updated without using InvalidateData() ?
        (why InvalidateData() is needed even if binding is redo ?)
    2 -    If InvalidateData() is mandatory, how to prevent grid to switch data between lines on screen ?
   
Thanks for your help.

Alain.

XamGrid_DataUpdate.zip
Parents
No Data
Reply
  • 4040
    Verified Answer
    posted

    Hi,

    After more investigation, we found a solution : RaiseDataMemberChanged.

    We had this problem because the View is informed when the object itself is updated (NotifyPropertyChanged) but not when one of the attributes is modified.

    Solution :

    • in project, add references to:
      • System.ComponentModel.DataAnnotations
      • System.ServiceModel.DomainServices.Client
    • in object class :
      • add "using System.ServiceModel.DomainServices.Client"
      • the object class must inherit from "ComplexObject"
      • in attributes/properties setters, use "RaiseDataMemberChanging" and "RaiseDataMemberChanged"

    See complete solution in attachment.

    Hope this will help other people.

    Alain.

     

    XamGrid_DataUpdate.zip
Children
No Data