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

  • SEARCH
  • Home
  • 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 722803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:01:57+00:00 2026-05-14T06:01:57+00:00

My stackpanels have gaps between each item (TextBlocks). You can see through to whatever

  • 0

My stackpanels have gaps between each item (TextBlocks). You can see through to whatever is behind on the background Canvas. I don’t want gaps.
I tried setting the margin of both the stackpanel and textblocks to zero. Didn’t fix it.
Creating the same thing in Blend shows no gaps (AFAIK).

stackpanel
(source: synthedit.com)
Here you can see the object behind mouse/moose showing thru the gap.

StackPanel^ tstack = gcnew StackPanel;
canvas->Children->Add( tstack );
canvas->SetLeft( tstack, 100 );
canvas->SetTop( tstack, 100 );
canvas->SetZIndex( tstack, 3 );

TextBlock^ tBlock = gcnew TextBlock();
tBlock->FontSize = 10;
tBlock->Text = L"mouse";
tBlock->Background = Brushes::LightGray;
tstack->Children->Add( tBlock );

tBlock = gcnew TextBlock();
tBlock->FontSize = 10;
tBlock->Text = L"moose";
tBlock->Background = Brushes::LightGray;
tstack->Children->Add( tBlock );
  • 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-05-14T06:01:57+00:00Added an answer on May 14, 2026 at 6:01 am

    There should be no need to set margins. A simple test in Kaxaml confirms that there should be no gap between elements. Two possible causes would be 1) an implicit style that is set in your application resources or somewhere in the visual tree or 2) SnapsToDevicePixels=false or UseLayoutRounding=true somewhere in the visual tree.

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

Sidebar

Related Questions

I have a StackPanel that contains child StackPanels (added in code behind). Parent StackPanel
I'm trying to have a background image on an image control in WPF, such
I have some StackPanels I wish to have the same Width. However this should
On my application i have 3 stackpanels that their visibility is binding to 3
I'm currently working on dynamically inserting Textblocks into Stackpanels. This has to be done
I have stackpanel in a canvas The stackpanel has <Canvas x:Name=MyCanvas> <Slider Template={StaticResource simpleSlider}
I have a WPF StackPanel that looks like this: (some attributes removed that don't
If I have a ChildWindow in Silverlight I can apply the FontSizeProperty and it
I have several StackPanels that change visibility based on ToggleButtons. The code below works
I have a StackPanel and for some reason I can't get the content of

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.