Home All Groups Group Topic Archive Search About

WPF/Avalon: Adding Controls During Runtime

Author
12 Feb 2007 6:24 PM
hufaunder@yahoo.com
I have to present inputs (textbox, combobox, etc) that are not known
during design time. In the past this was pretty simple to do. You just
add a new control to the Controls property of a form. How can I
achieve the same thing with WPF?

Thanks

Author
12 Feb 2007 7:54 PM
Willy Denoyette [MVP]
<hufaun***@yahoo.com> wrote in message
news:1171304670.816380.68960@j27g2000cwj.googlegroups.com...
>I have to present inputs (textbox, combobox, etc) that are not known
> during design time. In the past this was pretty simple to do. You just
> add a new control to the Controls property of a form. How can I
> achieve the same thing with WPF?
>
> Thanks
>


Please post XAML, WPF, WCF and WF questions to the msdn forums:

http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=153&SiteID=1

Willy.
Author
13 Feb 2007 1:24 AM
RobinS
You can post these questions to
microsoft.public.windows.developer.winfx.avalon as well as the MSDN forums
already mentioned since it seems to annoy the C# group to post them there.

As you know (hopefully), the Window has a Content property that can only be
set to one thing. You don't state if your window is blank or already has a
panel or something in it.

If you have a panel, you can just add children to it.

  Button btn = New Button();
  btn.Content = "Yo Dude"
  myStackPanel.Children.Add(btn);

If you have an empty window, you can just set its content:

  Button btn = New Button();
  Content = btn;

Hope this helps.
Robin S.
-------------------------------------------
<hufaun***@yahoo.com> wrote in message
Show quote
news:1171304670.816380.68960@j27g2000cwj.googlegroups.com...
>I have to present inputs (textbox, combobox, etc) that are not known
> during design time. In the past this was pretty simple to do. You just
> add a new control to the Controls property of a form. How can I
> achieve the same thing with WPF?
>
> Thanks
>

AddThis Social Bookmark Button