#187 – Adding Controls to a Window Using Visual Studio

In Visual Studio, you can add user interface controls to a window by dragging them onto a design surface.  Start by double-clicking on the window’s .xaml file in the Solution Explorer.

This will open the window in a design view editor.  The editor will have a design surface at the top and a XAML editor below that.

You can add new controls to the window by dragging them onto the design surface in the top pane or by editing the XAML directly.

To drag a control onto the design surface, find the list of WPF controls in the Toolbox window.  Once you find the control that you want, left-click and drag it onto the window’s design surface.  In the example below, we add a CheckBox to the window.

When you’re done dragging, the new control will show up both on the design surface and in the XAML.

Advertisements