Making a Button Fill the Cell Of a Grid

I'm trying to get a XAML Button to completely fill a cell in a Grid control.  I've set Padding and Margins to 0 and set alignment to Stretch but the button does not fill the cell completely.
LVL 1
DodsworthAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DodsworthConnect With a Mentor Author Commented:
Ah.. I'm developing for Windows Phone.  I just found out that the WP Button has a "touch-target overhang.", which prevents it from filling all the cell.

I used a Border and a StackPanel in the end.
0
 
David Johnson, CD, MVPOwnerCommented:
set the dimensions of the button and the cell to the same size
0
 
DodsworthAuthor Commented:
but my row and column defs are Width and Height ="*"
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Bob LearnedCommented:
How are the Grid and Button controls declared in the XAML?
0
 
aikimarkCommented:
are you coding in VB.Net or C#?
0
 
DodsworthAuthor Commented:
It's XAML.  No code behind...

<Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Button Content="Button" Grid.Column="0" Grid.Row="0"/>          

Open in new window

0
 
Bob LearnedCommented:
I don't see where you have set HorizontalAlignment and VerticalAlignment to "Stretch".
0
 
DodsworthAuthor Commented:
I took it out as it made no difference.
0
 
Bob LearnedCommented:
I took that XAML, and pasted it into a window, and it is stretched for me.

Button stretched in grid
0
 
Bob LearnedCommented:
Sometimes, it just comes down to the unknown factor...
0
 
DodsworthAuthor Commented:
solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.