views:

463

answers:

1

Hello,

Before asking this question I have looked at all related questions, but have not found anything relevant.

In my application I have toolbox style bar, which is basically stack panel with bunch of buttons. User may change which buttons are shown in toolbar.

Window width may be changed, but it can not be smaller then width of toolbar.

At first I was hoping to bind MinWidth property to StackPanel Width property and create converter that adds few pixels to Width of StackPanel. The problem is that my converter does not get Width of StackPanel, just NaN as value :(

Unfortunately StackPanel width is set to Auto and I can not change that.

Is there any way I can make my Window MinWidth dependable on Width of StackPanel?

Thank You.

+4  A: 

Use ActualWidth, not Width.

Width is the requested width, or NaN for "Auto", ActualWidth is the, well, actual width after all the layout is calculated.

Nir
That's great! I've been wanting to know how to do this myself.
j0rd4n
Thank You for you answer!I've tried using ActualWidth, but it creates another problemPlease have a loot at this screen shothttp://dl.getdropbox.com/u/204110/actualwidth.PNGThis solution won't let me make Window's width smaller, it only allows me to increase Width
Daniil Harik
Explicitly set HorizontalAlignment to left, works like charm...Thank You.
Daniil Harik