WPF tutorial four; layout dockpanel panel

Source: Internet
Author: User

DockPanel: Docking panel

DockPanel defines an area in which you can arrange child elements to be arranged as strokes, which are located in the Children property. Docking panels are similar to the dock properties of controls in WinForm. DockPanel will sort each child element and will dock according to the specified edge, and multiple elements docked on the same side are sorted sequentially. In DockPanel, controls that specify docking edges occupy corners according to the defined order, and all controls never overlap.

By default, elements that are added later can only use the remaining space, and the child element will always fill the remaining space, regardless of any docking value set on the last child element of DockPanel. If you do not want the last element to fill the remaining area, you can set the DockPanel property LastChildFill to False, and you must explicitly specify the docking direction for the last child element.

1. Fill the remaining space

Using XAML code implementations:

1<window x:class="Wpfdemo.mainwindow"2xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"3xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"4title="dockpanel Panel"height="237"Width="525"windowstartuplocation="Centerscreen">5<DockPanel>6<button dockpanel.dock=" Left"Content="Buttonleft"></Button>7<button dockpanel.dock="Top"Content="Buttontop"></Button>8<button dockpanel.dock=" Right"Content="Buttonright"></Button>9<button dockpanel.dock="Bottom"Content="Buttonbottom"></Button>Ten<button content="Buttontop"></Button> One</DockPanel> A</Window>

2, the last element does not fill the remaining space

Using XAML code implementations:

1<window x:class="Wpfdemo.mainwindow"2xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"3xmlns:x="Http://schemas.microsoft.com/winfx/2006/xaml"4title="dockpanel Panel"height="237"Width="525"windowstartuplocation="Centerscreen">5<dockpanel lastchildfill="False">6<button dockpanel.dock=" Left"Content="Buttonleft"></Button>7<button dockpanel.dock="Top"Content="Buttontop"></Button>8<button dockpanel.dock=" Right"Content="Buttonright"></Button>9<button dockpanel.dock="Bottom"Content="Buttonbottom"></Button>Ten<button dockpanel.dock="Top"Content="Last button does not fill the remaining space"></Button> One</DockPanel> A</Window>

WPF tutorial four; layout dockpanel panel

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.