Synchronizing properties

2 posts, 0 answers
  1. guga
    guga avatar
    11 posts
    Member since:
    Mar 2012

    Posted 26 Apr 2012 Link to this post

    Good afternoon. I am having problems with synchronization of properties in a RadPropertyGrid.

    This is my xaml

    <telerik:RadPropertyGrid Name="rpgPropertyEditor" Item="{Binding}" AutoGeneratePropertyDefinitions="False"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    LabelColumnWidth="130">
               <telerik:RadPropertyGrid.PropertyDefinitions>
                   <telerik:PropertyDefinition DisplayName="Nombre" Binding="{Binding nombre, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}" GroupName="General" Description="Nombre del recurso dentro del item"/>
                   <telerik:PropertyDefinition DisplayName="Cantidad" Binding="{Binding cantidadAsignada, Mode=TwoWay, ValidatesOnNotifyDataErrors=True}" GroupName="Valuación" Description="Cantidad de recursos asignados al item"/>
               </telerik:RadPropertyGrid.PropertyDefinitions>
               <i:Interaction.Behaviors>
                   <behaviors:RadPropertyGridDefualtViewCategoriesBehavior/>
                   <behaviors:RadPropertyGridIsPropertyEnabledBehavior IsDisabledCollection="{Binding DisableProperties}"/>
               </i:Interaction.Behaviors>
           </telerik:RadPropertyGrid>

    In my ViewModel, I have declared the properties.

    private String _nombre;
    public String nombre
    {
        get
        {
            return _nombre;
        }
     
        set
        {
            if (_nombre != value)
            {
                _nombre = value;
                RaisePropertyChanged("nombre");
                SynchronizeChange("nombre", value);
            }
        }
    }
    private double? _cantidadAsignada;
    public double? cantidadAsignada
    {
        get
        {
            return _cantidadAsignada;
        }
     
        set
        {
            if (_cantidadAsignada != value)
            {
                _cantidadAsignada = value;
                RaisePropertyChanged("cantidadAsignada");
                SynchronizeChange("cantidadAsignada", value);
            }
        }
    }

    When loading the ViewModel, runs a method that Sets an object with these properties.

    For example:


    nombre = object.nombre;

    In this way, I can load the property values ​​in my RadPropertyGrid and by a SynchronizeChange, tell my object, that changed them.

    The problem arises when the business logic, modify one of these properties, and to be charged to the View, is not aware of the modification.

    As I can do to learn of changes in my objetct?

    This would be much easier to solve if I could load the properties as "Binding OBJETCT.PROPERTY, Mode = TwoWay". But as far as I have understood, this does not work very well in the RadPropertyGrid.

    Thanks in advance.
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 27 Apr 2012 Link to this post

    Hello,

    I have tried to reproduce this issue on our side but I did not have any success. I am attaching my test project for your reference. Would you please share with us whether there sre any differences between my approach and yours?

    Kind regards,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. DevCraft banner
Back to Top