I'm having some problems with the layout of buttons on a screen. There are a number of buttons with the visibility set to collapsed depending on certain criteria.
Anyway, with the buttons sitting in a stackpanel, the contents determine the width of the buttons. Because these should share the same size, I put them in a grid where the columns are using the SharedSizeGroup.
Having done this, buttons now all share the same width, t开发者_C百科he smallest width needed to display the button with the largest content. What it does mean though is that buttons don't display at the required position.
That is - assume five buttons in columns 0-4 where the first button is collapsed, buttons should ideally all shift to the left so that they always occupy space left to right. Is there any way I can accomplish this or, if not, how can I get buttons in a stackpanel to share the same width?
Any help is much appreciated.
You can wrap your buttons with individual grids and use that to set a shared size, the scope should be the stackpanel. Then control the visibility of the individual grids instead of the buttons, this is a bit messy though.
Edit: This is probably what you need:
<UniformGrid Rows="1" HorizontalAlignment="Left">
...
精彩评论