All controls are always
added during run time, anyway. You don't see it directly only because you add some controls (or all of them) in XAML, and the actual "adding" code is not shown to you as the source code, because the real source is XAML. But you don't think they are added my some mystical "force", do you?
Here is what happens: you author layout in XAML, and, during the build, the actual code is first generated using the XAML, compiled in a usual way and used by application.
So, now you want to do some of such code with your own hands? Right, there are many cases when you really need it; and XAML is just awkward to use or does not provide enough expressing capabilities. There is a lot of code which cannot be expressed in XAML.
So, here is my, very general advice which will cover many similar questions. First, try to do what you need in a simplified sample, in XAML, in some temporary prototype application. Build it. Find auto-generated C# files — if will find them in directory structure under the location of the project file. Load the files and see how things work in C#. Learn it and then use in your work.
Simple and general, isn't it? This approach never failed.