Hello,
I have to create the properties at run time in modal class and have to attach INotifyInterface to those columns. Also I have to create the observable collections at run time and bind it to grid view.
I am really confused about how to achieve this functionality. Can anyone please help me out on this?
If you explain it with sample application then it will be really appreciated.
Thanks,
Asim Bagwan
Loading
Jaganathan BantheswaranPosted Dec 18, 2013, 1:21 AM
Meanwhile,
You can add properties dynamically in two ways,
1. using ExpandoObject
var dynamicObject = new ExpandoObject();
dynamicObject.YourPro1 = "Your Value 1";
dynamicObject.YourPro1 = 1234;
2. using Dictionary
public class MyClass
{
public string Template { get; set; }
public string Term { get; set; }
public Dictionary
public MyClass()
{
Properties= new Dictionary
}
public void AddProperty(string key, string value)
{
Properties.Add(key, value);
}
}
// to be used like this:
MyClass instance = new MyClass();
instance.AddProperty("Email", "[email protected]");
instance.AddProperty("Phone", "976856734");
3. using Reflection Emit
Please read here with Example.