This is a migrated thread and some comments may be shown as answers.

Synchronizing properties

1 Answer 71 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
guga
Top achievements
Rank 1
guga asked on 26 Apr 2012, 06:51 PM
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.

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 27 Apr 2012, 03:53 PM
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 >>
Tags
PropertyGrid
Asked by
guga
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or