Add items to popup programmatically
c#, popup, wpf
Solution
Popup is a FrameworkElement and can have only one child (Child) => you cannot add multiple controls inside, but you can set Child to be any UIElement you want. For instance a DockPanel, and than use AddChild on the panel to add further controls.
myPopup.Child = new DockPanel();
Problem
I need to create and add some items to a popup code-behind. It's easy to do this in XAML: ``` <Popup StaysOpen="False"> <DockPanel> //Items here </DockPanel> </Popup> ``` I think "Child" is where I need to add my items but I don't see any "Add", "Items", "Source" or "Content" inside. Does anyone know how to do this? ``` Popup myPopup= new Popup(); myPopup.Child // ... need to add items there ```