tags:

views:

128

answers:

1

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

For example, I want to allow GridSplitter to arbitrarily resize the column, but the initial (Auto) Width should not exceed a specific value. Same for the elements -- I want to allow resizing, but limit the Width they have if never resized.

MaxWidth works exactly as opposite -- it does not affect Auto Width of Grid Columns (it might be a bug), but limits the resized width.

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

+1  A: 

Try binding the MaxWidth to the Width and use a IValueConverter to react to changes from Auto to specific values.

David Schmitt
So basically use the MaxWidth, but remove it as soon as the Width stops being Auto? Very good idea -- thanks.
Andrey Shchekin
Unfortunately, this causes a problem -- user can not resize the element unless he already has resized the element.
Andrey Shchekin
Since this is a one-time thing, you could also try to react on the GridSplitter.Click and unset MaxWidth at the moment the users starts the drag.
David Schmitt