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 8849367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:37:57+00:00 2026-06-14T12:37:57+00:00

It seems that there are spacing between each item container, also margin and padding

  • 0

It seems that there are spacing between each item container, also margin and padding in the container. My question is how to calculate the actual size of a ItemContainer in GridView so that I can calculate how many the rows the grid would accommodate. What I can get are each ItemTemplate’s height, and the grid’s height. Given those values, how to calulate?

  • 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-14T12:37:59+00:00Added an answer on June 14, 2026 at 12:37 pm

    If you create a template Grid App, add a NuGet reference to winrtxamltoolkit debugging components and add a breakpoint in the Standard250x250ItemTemplate by setting

    Debugging:VisualTreeDebugger.BreakOnLoaded="True"
    

    where

    xmlns:Debugging="using:WinRTXamlToolkit.Debugging"
    

    you will see the visual tree trace like this in the output window of VS:

    path[8] is Control: Windows.UI.Xaml.Controls.GridViewItem():
        ActualWidth=258
        ActualHeight=258
        Position – X=376, Y=176, Right=634, Bottom=434
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        HorizontalContentAlignment=Center
        VerticalContentAlignment=Center
        Content=Item Title: 3
        Margins=0,0,2,2
        Padding=0,0,0,0
        Background=SolidColorBrush: #00FFFFFF
        Foreground=SolidColorBrush: #FFFFFFFF
        FontFamily: Segoe UI
    path[7] is Control: Windows.UI.Xaml.Controls.Border(OuterContainer):
        ActualWidth=258
        ActualHeight=258
        Position – X=376, Y=176, Right=634, Bottom=434
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        Margins=0,0,0,0
    path[6] is Control: Windows.UI.Xaml.Controls.Grid(ReorderHintContent):
        ActualWidth=258
        ActualHeight=258
        Position – X=376, Y=176, Right=634, Bottom=434
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        Margins=0,0,0,0
        Background=SolidColorBrush: #00FFFFFF
    path[5] is Control: Windows.UI.Xaml.Controls.Border(ContentContainer):
        ActualWidth=258
        ActualHeight=258
        Position – X=376, Y=176, Right=634, Bottom=434
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        Margins=0,0,0,0
    path[4] is Control: Windows.UI.Xaml.Controls.Grid(InnerDragContent):
        ActualWidth=258
        ActualHeight=258
        Position – X=376, Y=176, Right=634, Bottom=434
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        Margins=0,0,0,0
        Background=
    path[3] is Control: Windows.UI.Xaml.Controls.Border(ContentBorder):
        ActualWidth=250
        ActualHeight=250
        Position – X=380, Y=180, Right=630, Bottom=430
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        Margins=4,4,4,4
    path[2] is Control: Windows.UI.Xaml.Controls.Grid():
        ActualWidth=250
        ActualHeight=250
        Position – X=380, Y=180, Right=630, Bottom=430
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Stretch
        VerticalAlignment=Stretch
        Margins=0,0,0,0
        Background=
    path[1] is Control: Windows.UI.Xaml.Controls.ContentPresenter(contentPresenter):
        ActualWidth=250
        ActualHeight=250
        Position – X=380, Y=180, Right=630, Bottom=430
        DataContext: Item Title: 3 HashCode: 9648315
        HorizontalAlignment=Center
        VerticalAlignment=Center
        Margins=0,0,0,0
    path[0] is Control: Windows.UI.Xaml.Controls.Grid():
        ActualWidth=250
        ActualHeight=250
        Position – X=380, Y=180, Right=630, Bottom=430
        DataContext: Item Title: 3 HashCode: 9648315
        Width=250
        Height=250
        HorizontalAlignment=Left
        VerticalAlignment=Stretch
        Margins=0,0,0,0
        Background=
    

    Now since that item template uses a 250×250 Grid as its root and the GridView is using the default style with the default ItemContainerStyle – it seems like the default GridViewItem style has one Border called ContentBorder that defines a Margin of “4”. Depending on how your grid items are configured you can use that knowledge to calculate the size you are looking for in different ways.

    If you define a constant size ItemTemplate – like the 250×250 one in the Grid App project template – you end up with items that occupy 258×258 squares of space. If you change the ItemContainerStyle to change the Margins around each ContentBorder – you would have to adjust your calculations. If you don’t specify constant size for your ItemTemplate – your item sizes will be based on the first item added to the GridView.

    You can use Blend to analyze the control templates in more details or use the VisualTreeDebugger, XAML Spy or your own code that walks the visual tree using VisualTreeHelper to learn more about the layout.

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

Sidebar

Related Questions

It seems that there is a implementation of rope in my /usr/include/c++/4.5.1/ext/rope (and ropeimpl.h
It seems that there is a guidance that a model should not expose its
It seems that there are several really fast prime factorization algorithms around (one that
After looking at RescueTime for windows/mac, it seems that there's a version for linux
How can I add an URL to the trusted site? It seems that there
I know, I know, its sounds silly, but it seems that there are no
Given that: There seems to be no easy way to get a list of
It seems to me that there are two scenarios in which to use JOINs:
I've found that there seems to be a problem using css transitions properties when
It seems that these two operators are pretty much the same - is there

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.