2

How can I automatically (or maybe using a recalculate method) to automatically resize the width of a listview in WPF after items have been changed (e.g. using a new source, filter or just added or changed items manually) in such a way that the width of each column accomodates exactly the width of the largest item length (or column name length)?

1 Answer 1

1

Perhaps you could bind the width property to the "largest" item in the list? Guess you could use a custom converter for it...

Cheers --Jocke

Sign up to request clarification or add additional context in comments.

3 Comments

I would hope there would be a more 'automated' way. Calculating the largest can be quite tricky (regarding theme, font size etc).
I think you are out of look there. But if you don't want to implement the search algorithm yourself perhaps you can use array.Max (for ints) by first extracting the data. How does the list items look? stackoverflow.com/questions/4906725/…
They are strings depending from 1 to 100s of characters, problem is the proportional font of course. It's not a matter of life and death, I currently just use a fixed value which works reasonably well, but I noticed that when I don't specify the width manually initially all columns are equal to the max width string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.