New to WPF, let ListBox display in a matrix like ACDSee

Source: Internet
Author: User

ListBox is arranged from top to bottom by default. If you want to see the scaling mode of ACDSee or the content mode of Windows resource manager, you need to change the default panel of ListBox:

 

Replace the default panel of ListBox with wrappanel, but there is another key point:
If your wrappanel uses the horizontal direction (default), set scrollviewer. horizontalscrollbarvisibility = "disabled"; otherwise, it will continue to extend horizontally. In this case, the itemheight of wrappanel is auto, so that the height of each row is the same.

 

<ListBox itemssource = "{binding source = {staticresource colorsprops }}" <br/> itemtemplate =" {staticresource colortemplate} "<br/> selectedvaluepath =" color "<br/> grid. row = "0" grid. column = "0" <br/> scrollviewer. horizontalscrollbarvisibility = "disabled"> <br/> <ListBox. itemspanel> <br/> <itemspaneltemplate> <br/> <wrappanel/> <br/> </itemspaneltemplate> <br/> </ListBox. itemspanel> <br/> </ListBox> <br/>

Similarly, if your wrappanel uses the vertical direction, you need to set scrollviewer. verticalscrollbarvisibility = "disabled", otherwise it will always extend vertically. In this case, the itemwidth of wrappanel is auto, so that the width of each column is the same.

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.