Como: Criar um layout com base no posicionamento absoluto
O WPF Designer for Visual Studio fornece um Canvas painel de controle que suporte o posicionamento absoluto. You can use the Canvas panel control to position elements absolutely in your applications.
Importante |
---|
Whenever possible, it is preferable to use a dynamic layout. Dynamic layouts are the most flexible, adapt to content changes such as localization, and allow the end user the most control over their environment. To see examples of dynamic layouts, see Como: Criar um layout dinâmico and Passo a passo: Construindo um layout dinâmico. |
Adding a Panel Control
By default, each new WPF application contains a Window with a Grid panel. To create a layout based on absolute positioning, you must use a Canvas panel. In this procedure you remove the default Grid and add a Canvas.
To add a panel control
In Design view, select the grid.
Observação You can select the grid in various ways, such as by clicking anywhere inside it or by using the TAB key. For more information about how to select elements in the WPF Designer, see Como: Selecionar e mover elementos na superfície de design.
Press the DELETE key to delete the Grid.
From the Toolbox, in the Controls group, drag a Canvas control onto the Window.
(Optional) In the Properties window, set the Height property of the Canvas to Auto.
(Optional) In the Properties window, set the Width property of the Canvas to Auto.
On the File menu, click Save All.
Adding Controls to the Panel
Next, you add controls to the panel and use the Left and Top attached properties of the Canvas to position them absolutely.
To add controls to the panel
Do caixa de ferramentas, arraste um controle para o Canvas.
In the Properties window, set the following properties for the control:
Canvas.Left
Canvas.Top
Observação Há dois conjuntos de propriedades mutuamente exclusivos: Left/ Right, and Top / Bottom. Only Left and Top are exposed in the Properties window, but you can specify Right and Bottom in the XAML editor. If you specify both Left and Right, only the last declaration is used. If you specify both Top and Bottom, only the last declaration is used.
Repeat steps 1 and 2 until all the necessary controls have been added to the panel.
On the File menu, click Save All.
Consulte também
Tarefas
Passo a passo: Construindo um layout com base no posicionamento absoluto
Conceitos
Layout com absoluto e dinâmica posicionamento
Visão geral do WPF e do Silverlight Designer