Spacing buttons equally across a window in WPF
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 *.
I'd like to see an example of how to easily get the UniformGrid to space the buttons equally if they are intended to retain their "natural" widths rather than being forced to have uniform widths.
In the meantime, perhaps this isn't the best solution, but it seems to work for me and might help the next person:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button x:Name="FirstBtn" Grid.Column="0" Content="_First" />
<!-- Skip column 1 so it will provide flexible space -->
<Button x:Name="SecondBtn" Grid.Column="2" Content="_Second" />
<!-- Skip column 3 -->
<Button Name="ThirdBtn" Grid.Column="4" Content="_Third" />
How about a Grid
or, even easier, UniformGrid
?