I'm in the situation I need to add a control. This control can be a button, label, a homemade control or whatever.
Point is I don't know which type it is.
I got a input which is a UIelement (called original), which has a type. Afterwards I need to create a control of the type UIelement original has.
For instance:
UIelement ele = new TYPE-OF-original;
Or even better:
UIelement ele = new UIelement;
ele.SetType = TYPE-OF-UIELEMENT;
Problem is I don't think you can set a type to a UIelement.
I can get the type of UIelement by the GetType() method. But how do I add it generic?
UIelement ele = new GetType(original)
.. Dosnt work either
Further on I might need to be able to set width/height of the control, which UIelement dosn't support.
Loading
Lars HoldgaardPosted Sep 17, 2009, 4:36 PM
I do know about inheritance, and I do know about the inheritance system in the .NET framework.
My specific problem is the following: I got a WPF application with drag & drop functionality using Adorner. I got a menu on the left of my screen, a bit like the one with controls in Visual Studio. In that menu I can drag some different controls out.
On the leftmousebuttonup event I need to add the a new instance of the control to the Canvas hence I need to know the type.
Sorry for bad explanation above.
Kumar AGPosted Sep 17, 2009, 4:02 PM
Roei BarPosted Sep 17, 2009, 3:46 PM
do you need to add a control Dynamically?
why do you need to convert the Type to a specific Type?