Udostępnij za pośrednictwem


How to: Select and Move Elements on the Design Surface

The Windows Presentation Foundation (WPF) Designer for Visual Studio allows you to select and move elements by using mouse gestures or keyboard shortcuts. There are multiple ways that an element can be selected. For example, you can select an individual control by tabbing through the controls, by placing your cursor in the control tag of XAML view, by using the tag navigator at the bottom of the designer, or by using the Document Outline window. Once selected, controls can be positioned with the mouse or by using the arrow keys.

To select an element on the design surface

  • In Design view, while the design surface has the focus, press the TAB key until the desired element is selected.

    Pressing SHIFT+TAB takes you back in the order.

  • In XAML view, place your cursor in the start or end tag of the element.

  • If the element appears in the tag navigator, click the element.

  • In the Document Outline window, click the element.

  • To select the parent of a current selection in the designer, press the ESC key.

  • For enhanced precision, zoom in on an area to provide additional clickable areas.

To select multiple controls on the design surface

  • In Design view, using the mouse, drag to create a selection rectangle that encompasses the controls that you want to select.

  • In Design view, while pressing down the CTRL or SHIFT key, click each control you want to select. There is no way to select multiple controls on the design surface with keyboard only.

  • In the Document Outline window, while pressing the CTRL key, click the controls you want to select. You can also press CTRL+SPACEBAR to select multiple controls. Press the ESC key to reduce a multi-selection to a single selection.

To move selected controls in the designer

  • While holding down the left mouse button, drag the selected controls to the desired location.

  • If the selected control is a panel, such as a Grid, DockPanel, or StackPanel, use the move handle in the upper left to move the panel.

  • Position the selected controls by pressing the arrow keys.

  • In some cases, it may be necessary to cut and paste rather than move.

Note

Unlike with Windows Forms, the Document Outline window does not support moving or changing the parent of controls interactively.

See Also

Concepts

Navigating the Element Hierarchy of a WPF Document

Other Resources

WPF Designer