Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:16:10+00:00 2026-06-18T16:16:10+00:00

I have a grid of objects that I am generating programmatically. For testing purposes,

  • 0

I have a grid of objects that I am generating programmatically.

For testing purposes, each cell in the grid is a Border object whose child is an Image object. Each cell is placed flush against it’s neighbor and displays perfectly.

When I replace each Image object with a Button object (each cell is still a Border object, just with a Button for its child rather than an Image), a noticeable gap appears between cells.

I have tried setting margin, padding, et al to 0.

What is unique about Buttons that makes them behave this way, and how can I overcome it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:16:11+00:00Added an answer on June 18, 2026 at 4:16 pm

    Margin is defined in the control template. you can change it by following these steps:

    Right click on a button in the designer and select Edit Template > Edit a Copy... from the context menu.

    Context menu

    In the dialog select the name for the new style and choose where you want to put it.

    Create style dialog

    Now find the following block of XAML in the style and set Margin to 0.

    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="3">
        <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
    </Border>
    

    Assign the new style to all your buttons by either removing x:Key from the style declaration:

    <Style TargetType="Button">
        <!-- style definition -->
    </Style>
    

    Or by setting the style to selected buttons:

    <Button Style="{StaticResource MyButtonStyle}"/>
    

    Either way, you’ll have your buttons next to each other without any gap between them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grid that binds a number of child data objects to columns
I'm going to have a 10x10 grid of UIButton objects. Each of these UIButtons
I have an object that will populate a grid with the ability to delete
I have a program that contains a 2d grid of panel objects and I
I have multiple simple circle objects in grid of an image from which I
I have a simple question. Can a grid automatically resize the objects in it
Say I have a grid, I click an object and it displays in a
I have grid with some textboxes and an image which goes out of grid
I have grid of images, when the mouse is over any given image a
I have a collection of custom data objects that I display in DataGrid. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.