Reputation: 11972
I have the below XAML which shows some padding under the buttons in the UniformGrid:
<Grid>
<UniformGrid Background="#CCC"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Margin="8,8,8,0">
<Button Height="28"
Margin="5">
OK
</Button>
<Button Height="28"
Margin="5">
Cancel
</Button>
</UniformGrid>
</Grid>
It displays as:
But if I remove one of the buttons, no padding will occur:
How can I remove this padding when 2 buttons are in the XAML?
I have tried the obvious Padding
and Margin
properties but it remains the same.
Upvotes: 1
Views: 771
Reputation: 988
Try specifying the number of rows:
<UniformGrid Rows="1" />
UniformGrid will automatically set the number of columns and rows according to the number of elements added to it. Take a look at this post.
Upvotes: 5
Reputation: 11972
I have found that setting the number of columns = 2 will fix the problem, as in:
<UniformGrid Columns="2" />
Although I still don't know why this won't work without setting the columns, if anyone can explain I would appreciate.
Upvotes: 0