There are two ways to get controls in your window:
- Do the whole designing stuff in the Designer of VisualStudio
Add the controls by code. Here is a short, simple sample of creating a window and putting controls in it:
var window = new Window();
var stackPanel = new StackPanel { Orientation = Orientation.Vertical };
stackPanel.Children.Add(new Label { Content = "Label" });
stackPanel.Children.Add(new Button { Content = "Button" });
window.Content = stackPanel;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…