Solved

Making a Button Fill the Cell Of a Grid

Posted on 2014-04-14
12
437 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 81

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Simple Linear Regression
Progress

687 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