dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7k stars 1.16k forks source link

Disable WPF Listview Column Resizing #9412

Open vsfeedback opened 1 month ago

vsfeedback commented 1 month ago

This issue has been moved from a ticket on Developer Community.


Add a property to prevent resizing of a column in a WPF Listview but still make it sortable.

There is one way around this, but it disables sorting on that column.


Original Comments

Feedback Bot on 12/1/2022, 08:40 AM:

(private comment, text removed)

miloush commented 1 month ago

I don't think that is a good practice and some effort should be required on the developer side to enforce this.

The effort is pretty minimal anyway:

public class NonResizableGridViewColumnHeader : GridViewColumnHeader
{
    public override void OnApplyTemplate()
    {
        if (Role != GridViewColumnHeaderRole.Normal)
            base.OnApplyTemplate();
    }
}