The behavior of using custom panel in WPF to better handle resize

Source: Internet
Author: User

WPF has a lot of pane, but the functionality is too basic. Support for some common features is not very convenient. Some of the following situations should have been encountered by many people.

There is a margin between the item in 1.Panel. But deal with the last or first item specifically: It doesn't need this margin.

2. The window in the process of resize, the item will appear each other occlusion or the occurrence of an item is only partially visible. At this point we would prefer the item to be simply hidden.

3. It is difficult to adjust the order of the item at run time. (Note that the panel is not ItemsControl, this problem is easy for the latter, direct control of the background bound data can be)

4. The size of the item within the Panel is automatically adjusted according to the size of the panel.

These issues are often encountered in implementation projects, but WPF does not provide a dedicated panel to handle all of these issues perfectly. The following is a specific introduction to these issues.

The 1th question is so common that it doesn't explain much.

The 2nd question, an item, if the place is not fully displayed, then do not show it. Show out how ugly the semi-finished products, but not to show. Originally wanted to do a autohidebehavior, the results found not so easy, because a control is displayed by its parent control, and the arrange process does not define what event can be controlled. The best way to do this is to use a custom panel. WPF has brought a panel like this, called Toolbarpanel. This panel is really from the door to sweep the snow Ah, the realization of the toolbar need to complete the function, want to be used elsewhere, the behavior is not worthy of, can only do one.

For the header of the problem 4,tabcontrol is an example, WPF specifically makes a tabpanel to control the layout of the tab header, which automatically fills the header's width when the tab header has two rows. I wonder if Ms can do a general panel called Autofillwrappanel, or provide WrapPanel with a autofill attribute? This can also be done by defining the maxwidth and MinWidth attributes for each child, but this is a hard code, a magic number.

Discontent makes progress. MS, if any function is done, those control developers are not going to fall?

This is based on the basic behavior of StackPanel, adding some extension functions. Including:

1.ItemMargin: Control the spacing between the item in the panel

2.Orientation: Control the placement direction of the item in the panel. The StackPanel function.

3.ItemExtraWidth: When the panel is wide enough, give the maximum width allocated to each item inside.

4.ItemExtraHeight: When the panel is high enough, give the maximum height allocated to each item inside.

5.LastVisualChildFill: Shows whether the last item fills the remaining space of the panel.

6.IsParticalItemHidden: When the panel's remaining space is not sufficient to display the current item fully, it is not displayed.

7.arrangemanager.arrangeindex: Controls the rendering order of the Panel's children. The default is to define the order.

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.