[Original] dockpanel docking and default filling in the WPF main interface Layout

Source: Internet
Author: User

In WPF, usually the main interface is mostly the dockpanel root element, a dockpanel. top Main Menu, dockpanel. top toolbar, dockpanel. A bottom statusbar is used to create a main area of fill. However, there is often a misunderstanding about how to fill the elements that are full of space, because the dockpanel does not have a dockpanel. fill attribute. The actual method is to dock the menu, toolbar, statusbar, and so on through the dockpanel. top, dockpanel. bottom, dockpanel. left, dockpanel. add the fill area element. Note that the dockpanel attribute of this element cannot be set, the last added element will automatically fill the entire remaining space.

There is no explanation of this "technique" in this document, which leads to unnecessary time waste and is recorded here. I hope it will be helpful to you.

 

<Dockpanel name = "dockpanel1">
<Menu Height = "23" name = "menu1" dockpanel. Dock = "TOP">
<Menuitem header = "user management">
<Menuitem header = "Change Password"> </menuitem>
<Menuitem header = ""> </menuitem>
</Menuitem>
<Menuitem header = "Tower management">
<Menuitem header = "added"> </menuitem>
<Menuitem header = "modify"> </menuitem>
<Menuitem header = "delete"> </menuitem>
</Menuitem>
<Menuitem header = "Communication Management">
<Menuitem header = "start/stop inspection"> </menuitem>
<Menuitem header = "communication test"> </menuitem>
<Separator/>
<Menuitem header = "parameter settings"> </menuitem>
</Menuitem>
<Menuitem header = "History query">
<Menuitem header = "start/stop inspection"> </menuitem>
<Menuitem header = "communication test"> </menuitem>
<Separator/>
<Menuitem header = "parameter settings"> </menuitem>
</Menuitem>
<Menuitem header = "help"/>
</Menu>
<Toolbarpanel Height = "26" name = "toolbarpanel1" dockpanel. Dock = "TOP" orientation = "horizontal">
<Toolbar>
<Button> 111 </button>
<Button> 222 </button>
</Toolbar>
<Toolbar margin = ", 0,">
<Button> 111 </button>
<Button> 222 </button>
</Toolbar>
</Toolbarpanel>

<Statusbar Height = "23" name = "statusbar1" dockpanel. Dock = "bottom" verticalignment = "bottom"/>

 

<! -- Note that no dockpanel. Dock attribute is set for grid: -->

<Grid>
<Grid. rowdefinitions>
<Rowdefinition Height = "Auto"/>
<Rowdefinition/>
<Rowdefinition Height = "240" type = "regxph" text = "yourobjectname"/>
</Grid. rowdefinitions>
<Grid. columndefinitions>
<Columndefinition width = "240" type = "codeph" text = "/codeph"/>
<Columndefinition/>
</Grid. columndefinitions>

<Gridsplitter grid. rowspan = "2" grid. Column = "1" horizontalalignment = "Left" width = "5" name = "gridsplitter1" resizedirection = "columns"/>

<Wrappanel>
<Radiobutton margin = "5"> all </radiobutton>
<Radiobutton margin = "5"> three-pipe tower </radiobutton>
<Radiobutton margin = "5"> Angle Steel Tower </radiobutton>
<Radiobutton margin = "5"> single-tube tower </radiobutton>
</Wrappanel>
<Treeview name = "treeview1" grid. Row = "1">
<Treeviewitem header = "Lianyungang City">
<Treeviewitem header = "Tower 1"> </treeviewitem>
<Treeviewitem header = "Tower 2"> </treeviewitem>
<Treeviewitem header = "Tower 3"> </treeviewitem>
<Treeviewitem header = "Tower 4"> </treeviewitem>
</Treeviewitem>
<Treeviewitem header = "XXX City"> </treeviewitem>

</Treeview>

<Windowsformshost grid. row = "0" grid. rowspan = "2" grid. column = "1" name = "windowsformshost1" opacitymask = "{X: NULL}" background = "# ff190000"/>

<Image grid. Row = "2"> </image>

</GRID>
</Dockpanel>

 

If"Dockstyle. Dock"Set the property to top or bottom."Width"Set the property to auto. Similarly, if"Dockstyle. Dock"Set the property to left or right."Height"Set the property to auto.

By default, dockpanel is set to lastchildfill, which means that the last child control added to dockpanel sets its dockpanel. Dock attribute to fill. To change this behavior, set the lastchildfill attribute of dockpanel.

 

 

 

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.