WpfDesigner icon indicating copy to clipboard operation
WpfDesigner copied to clipboard

How do i add controls to my design surface programmatically?

Open Jerry2306 opened this issue 3 years ago • 0 comments

I want to add UserControls to my design surface programmatically. First i tried adding it to the children UIElementCollection for my root control (which is a grid). When i've done this i couldn't select the control on the surface, but it appeared. Then i tried it via the CreateComponentTool. With this i can select the control on the surface and move it. But the control is positioned outside my design panel (i think the design panel is the root document, were i can order my controls on and the design surface is the whole design control, containing the design panel?): image

As well the control must have VerticalAlignment->Bottom and HorizontalAlignment->Right. But i want it to be from Top, Left: image

I made the AddItemsWithDefaultSize method (in CreateCompnentTool) public so i can create my DesignItem and can pass it directly down, instead of letting the CreateComponentTool do this (i want to manipulate attributes of my obj). I have tried it as follows: image

My UserControl should not be the problem as it is added right via the toolbox.

Thanks in advance and best regards Jeremy

Jerry2306 avatar Jul 28 '22 07:07 Jerry2306