Reputation: 561
I'm creating a Dialog in WPF with pretty standard Save and Cancel buttons. I want the Save and Cancel buttons to have the same width. I thought this would be a trivial matter. I placed the buttons in a Grid, with two columns sized to '*', yet the columns have different widths!!
<Grid Grid.Row="2" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Content="Save" Margin="8" />
<Button Content="Cancel" Margin="8" Grid.Column="1" />
</Grid>
If I take off the Horizontal alignment, the columns size equally, but the Grid is too large. How do I get a Grid, aligned right, with two equal columns??
Upvotes: 1
Views: 99
Reputation: 913
try
<UniformGrid HorizontalAlignment="Right" Columns="2">
<Button Content="Save" Margin="8" />
<Button Content="Cancel" Margin="8" Grid.Column="1" />
</UniformGrid>
Upvotes: 1