Solved

Making a Button Fill the Cell Of a Grid

Posted on 2014-04-14
12
432 Views
Last Modified: 2014-05-18
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.
0
Comment
Question by:Dodsworth
12 Comments
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 39998630
set the dimensions of the button and the cell to the same size
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 39998640
but my row and column defs are Width and Height ="*"
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40035166
How are the Grid and Button controls declared in the XAML?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 45

Expert Comment

by:aikimark
ID: 40035182
are you coding in VB.Net or C#?
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 40035566
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40035840
I don't see where you have set HorizontalAlignment and VerticalAlignment to "Stretch".
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 40036511
I took it out as it made no difference.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40037111
I took that XAML, and pasted it into a window, and it is stretched for me.

Button stretched in grid
0
 
LVL 1

Accepted Solution

by:
Dodsworth earned 0 total points
ID: 40037154
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40037320
Sometimes, it just comes down to the unknown factor...
0
 
LVL 1

Author Closing Comment

by:Dodsworth
ID: 40073013
solved
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question