Hi,
I was wondering if there is a way of defining WPF components in the code behind, building a full UI inside a Grid, then inserting this into a global container (WPF or WinForms).
i.e. a textblock with 2 buttons --> added to -- > wrappanel --> inserted into a wpf window
all from code behind.
Thanks in advance.
Person.
Building an UI from code behind
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

naura paxRank #2,843 · 502 reputationPosted Jan 11, 2010, 1:34 AM EST
since you mentioned winforms, I would say yes you can do that.
In code you can instantiate each control as an object
DataGridView grdTest=new DataGridView();
and populate it with columns like wise (in fact if you observe winform there is a form.designer.cs file which contains control definitions and there relative position within the form in c#).
I haven't tried WPF till now but i'm sure its possible with it too :)
person91 reputationPosted Jan 11, 2010, 6:19 AM EST
No I mentioned WinForms as the parent container......no WPF is harder to build in code behind.
If anyone has any ideas please shout.
Thanks,
N Dean G.
Martin Cook46 reputationPosted Feb 10, 2010, 2:09 AM EST
I don't fully understand what you are trying to achieve but if you are talking about adding these controls repeatedly
Cheers,
Martin