The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
WPF Grid Margin? RRS feed

  • Question

  • How do I get rid of those huge space between each Grid? I tried Margin, Padding, BorderThickness. None of them is making those Button more compact Uploaded with ImageShack.us Thanks
    Thursday, February 23, 2012 12:54 AM

Answers

  • I just played with this in Expression Blend (EB).  I found that the visual margin between the buttons and the grid goes away if you set Margin="-12" for every button. 

    Be careful with this approach because you might end up with overlapping touch areas because they are buttons.
    A better approach might be to modify the whole button design by editing its ControlTemplate as a copy (in EB right click on a button and choose Edit Template)

    - Mark
    Thursday, February 23, 2012 4:28 PM
  • I just played with this in Expression Blend (EB).  I found that the visual margin between the buttons and the grid goes away if you set Margin="-12" for every button. 

    Be careful with this approach because you might end up with overlapping touch areas because they are buttons.
    A better approach might be to modify the whole button design by editing its ControlTemplate as a copy (in EB right click on a button and choose Edit Template)

    - Mark
    Thanks for the help! I found it Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="1"
    Thursday, February 23, 2012 6:16 PM

All replies

  • try using the actual pixel count you want instead of auto
    Thursday, February 23, 2012 2:27 AM
  • try using the actual pixel count you want instead of auto


    Thanks for the suggestion, but the button actually shrunk and the wide space is still there.
    Thursday, February 23, 2012 3:14 AM
  • I just played with this in Expression Blend (EB).  I found that the visual margin between the buttons and the grid goes away if you set Margin="-12" for every button. 

    Be careful with this approach because you might end up with overlapping touch areas because they are buttons.
    A better approach might be to modify the whole button design by editing its ControlTemplate as a copy (in EB right click on a button and choose Edit Template)

    - Mark
    Thursday, February 23, 2012 4:28 PM
  • I just played with this in Expression Blend (EB).  I found that the visual margin between the buttons and the grid goes away if you set Margin="-12" for every button. 

    Be careful with this approach because you might end up with overlapping touch areas because they are buttons.
    A better approach might be to modify the whole button design by editing its ControlTemplate as a copy (in EB right click on a button and choose Edit Template)

    - Mark
    Thanks for the help! I found it Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="1"
    Thursday, February 23, 2012 6:16 PM