I am trying to change properties of controls using strings for control name, control AssemblyQualifiedName, Property name and property value
What I have tried:
public void ChangeIt(string ctrlName, string typ,
string prop, string value)
{
Type t = Type.GetType(typ);
dynamic obj = Convert.ChangeType(App.Current.MainWindow.FindName(ctrlName), t);
// Now how to
// obj.Prop=value;
}
ChangeIt("Label1",
"System.Windows.Controls.Label, PresentationFramework, Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35",
"Content", "Hellow World!");
Thank you
You don’t really need the type at all, and you don’t need to use dynamic.