Solved

Making a Button Fill the Cell Of a Grid

Posted on 2014-04-14
12
428 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 78

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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

The problems with reply email signatures

Do you wish that you could place an email signature under a reply? Well, unfortunately, you can't. That great Exchange/Office 365 signature you've created will just appear at the bottom of an email chain. What a pain! Is there really no way to solve this? Well, there might be...

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now