[WPF Troubleshooter] How to qualify ListView column widths

Source: Internet
Author: User

One of the defect you encounter today is that you should limit the minimum width of columns in List view to prevent users from dragging the column width to 0 and causing the column to disappear. WPF's list view does not have a built-in mechanism, but we can track the width of the column and further limit the user's drag by listening to the user's drag and drop, and I've already done the problem, see the demo in the attachment.

The "Listviewlayoutmanagerlib" project in the demo has been encapsulated and how to use the package, please refer to the instructions below (or GRIDVIEWCODEDEMO.WINDOW1.XAML)

1, the introduction of Listviewlayoutmanagerlib into the project, Name Introduction namespace: Xmlns:listviewmgr= "clr-namespace:listviewlayoutmanagerlib;assembly= Listviewlayoutmanagerlib "

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

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

<listview listviewmgr:listviewlayoutmanager.enabled= "True" >
<listview.view >
<gridvie W allowscolumnreorder= "true" >
<gridviewcolumn
listviewmgr:rangecolumn.minwidth= "
   header= "MinWidth100"
width= "/> <gridviewcolumn listv
"
Iewmgr:rangecolumn.minwidth= "Listviewmgr:rangecolumn.maxwidth=" "
header=" Width100 ~200 "width="/>
<gridviewcolumn header= "Normal" width= "" "/>
</gridview>
   </ListView.View>
</ListView>

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.