Register PropertyInfo

Register PropertyInfo

Old forum URL: forums.lhotka.net/forums/t/9778.aspx


Lazaro posted on Wednesday, November 17, 2010

I have a doubt about defining properties metadata. When a property does not have a managed or private backing field associated to it, should I register a PropertyInfo for that property?

What is the formula to register or not register a PropertyInfo for a property?

I am asking because I do not see the purpose to register when you do not have any authorization or validation rules associated with the property.

Thanks,

Lazaro Falcon

JonnyBee replied on Wednesday, November 17, 2010

Hi,

If you are going to use Silverlight or Windows Phone you will automatically get serialization for managed properties.

Registered properties with private backing fields and other non-managed properties will require that you - the developer - add code for serialize/deserialize of values in each object.

I prefer to use registered properties, so if I need to add authorization or validation it's just a matter of adding it - no requirements to changing the way properties are declared and I keep the coding pattern using snippets.

 

 

 

tmg4340 replied on Thursday, November 18, 2010

If your property is nothing more than a calculation of other data (which is what I assume this property is), then I don't see any need to register it - there isn't anything to register anyway.  Your property is nothing but code, which already exists on both ends of your application.  So long as the underlying data that feeds this property's calculation is making it back and forth (i.e. those properties are registered), and you have no rules associated with the property, there's nothing for the framework's property-management system to manage.

HTH

- Scott

JonnyBee replied on Thursday, November 18, 2010

But, if you set PropertyChangedMode to PropertyChangedModes.Xaml you will get a PropertyHasChanged event raised for PrimaryProperty AND AffectedProperties - which would typically be used for calculated (affected) fields to be updated in the UI.

And in order to use AffectedProperties they must be registered properties.

Copyright (c) Marimer LLC