0

I have a model class that contains a range of properties. I am writing an MVVM Light service that will allow me to directly assign those properties which means I need to create both an interface and service.

Is there a way that I can do something like this

myService.SetProperty(propertyName, value)

and

var n = myService.GetProperty(propertyName)

where propertyName is always a string, but using reflection the correct property is found within the model class and set or read?

Nodoid
  • 1,449
  • 3
  • 24
  • 42
  • Yes this is possible ... ^^ Can you please post the code you have written for the moment and explain what kind of problem you encounter ? – Thomas Apr 07 '16 at 01:17

1 Answers1

0

You might wish to see setting-a-property-by-reflection-with-a-string-value.

or can-i-set-a-property-value-with-reflection

or PropertyInfo.SetValue Method on MSDN.

Community
  • 1
  • 1
Steinwolfe
  • 238
  • 2
  • 6