Solved

Making a Button Fill the Cell Of a Grid

Posted on 2014-04-14
12
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
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…

749 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