?
Solved

Making a Button Fill the Cell Of a Grid

Posted on 2014-04-14
12
Medium Priority
?
438 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 82

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 46

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Configuring Remote Assistance for use with SCCM
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

762 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