I am trying to get a value of a Window as follows
this refers to the main window (window1)
Type type = this.GetType();
PropertyInfo pi = type.GetProperty("Left");
object obj = pi.GetValue(type, null);
But I get an "Object does not match target type using" error. What is wrong?
Because you are trying to get the 'Left' property of a Type, not your instance.
try this
object obj = pi.GetValue(this, null);
use this code
object obj = property.GetValue(currentObject, null)
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With