How to limit the ListView column width [WPF troubleshooter]

Source: Internet
Author: User

Original: [WPF Troubleshooter] How to limit the width of a listview column

How to limit the ListView column width [WPF troubleshooter]
Zhou Banhui

One of the defect that is encountered today is to limit the column width in the list view to prevent the column from dropping by dragging the column width to 0 . The WPF list view does not have this mechanism built in, but we can monitor the user drag and drop to track the width of the column and further limit the user drag, I have already fixed the problem, please see the demo in the attachment.

Demo The "Listviewlayoutmanagerlib" project in the operation has been encapsulated, how to use the package, please refer to the following instructions (or GridViewCodeDemo.Window1.xaml)

1 , introduce listviewlayoutmanagerlib into your project with the name introducing namespaces: Xmlns:listviewmgr= "clr-namespace:listviewlayoutmanagerlib;assembly =listviewlayoutmanagerlib "

2 , enable listviewmanager:listviewmgr:listviewlayoutmanager.enabled= "True" on a ListView control that requires a qualifying operation

3 , set the qualifying value on the column that needs to be listviewmgr:rangecolumn.minwidth= "

<listview listviewmgr:listviewlayoutmanager.enabled= "True">

<listview.view >

<gridview allowscolumnreorder= "true" >

<gridviewcolumn

listviewmgr:rangecolumn.minwidth= "

Header= "MinWidth100"

Width= "/>"

<gridviewcolumn

listviewmgr:rangecolumn.minwidth= "

Listviewmgr:rangecolumn.maxwidth= "200"

Header= "width100~200" width= "/>"

<gridviewcolumn header= "Normal" width= "/>"

</GridView>

</ListView.View>

</ListView>

Demo download

How to limit the ListView column width [WPF troubleshooter]

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.