MaxAutoWidth in WPF

Is there a good way to constrain the Auto Width of an element or Grid Column? I want to limit only Auto Width, but allow any user changes.

For example, I want to allow the GridSplitter to arbitrarily resize a column, but the initial (auto) width must not exceed a certain value. Ditto for elements - I want to allow resizing but limit their width if they never resize.

MaxWidth works exactly the same as the opposite - it does not affect the automatic width of the grid columns (this might be a bug), but it does limit the width of the size.

Is there any good solution that works for almost any element or Grid part?

0


source to share


2 answers


Try to bind MaxWidth

to Width

and use IValueConverter

to react to changes from Auto

to specific values.



+1


source


In the column of the grid, set the width at which the column should start. Any changes to the column width made by the user using the grid divider will overwrite the width you start with.



0


source







All Articles