views:

143

answers:

2

What's the best control to arrange buttons horizontally across a window in WPF? I am having trouble arranging the buttons evenly while resizing the window. I tried to use the stack panel but the buttons just stay at their position and do not space out to fill up the window space. Tried to use the dock panel as well but no luck yet.

Can anybody suggest me a good way to do it or tell me if I am doing anything wrong?

+4  A: 

How about a Grid or, even easier, UniformGrid?

HTH,
Kent

Kent Boogaart
Thanks, I wasn't aware of the UniformGrid. That might solve my problem. :)
Saurabh Lalwani
+2  A: 

Hi Saurabh,

What are you doing wrong? You are ignoring MSDN section on the layout system in WPF :).

You can use Grid and set HorizontalAlignment/VerticalAlignment of buttons to Center, and grid column width should be *.

Anvaka
Thanks for the answer Anvaka .. but I guess UniformGrid seems to be doing it in a much cleaner and easier way.
Saurabh Lalwani