Skip to content

HeaderedItemsControl margin is doubled #844

@joelspadin

Description

@joelspadin

Describe the bug

If you set the Margin property on a HeaderedItemsControl, the actual margin applied is double the value set.

I suspect this is caused by

<ItemsPresenter Margin="{TemplateBinding Margin}"
because if I create a copy of the style with the margin removed, then the margin is only applied once.

This issue doesn't apply to the Padding property though, even though that is set in the template similarly. Padding is not doubled, and removing the padding from the style causes no padding to be applied. I'm not familiar enough with how this works to know why margin and padding are handled differently here, so I don't know if the fix is to simply remove the margin from the style, or if that would cause other issues.

Steps to reproduce

1. Create a WinUI 3 project with a `HeaderedItemsControl` containing some items. Measure the space around the items.
2. Add `Margin="10"` to the control. Measure the space around the items and observe that it is 20 larger than before instead of 10.

Expected behavior

The amount of margin applied should be the exact value given.

Screenshots

No response

Code Platform

  • UWP
  • WinAppSDK / WinUI 3
  • Web Assembly (WASM)
  • Android
  • iOS
  • MacOS
  • Linux / GTK

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 10 21H2 (Build 19044)
  • Windows 10 22H2 (Build 19045)
  • Windows 11 21H2 (Build 22000)
  • Windows 11 22H2 (Build 22621)
  • Windows 11 23H2 (Build 22631)
  • Windows 11 24H2 (Build 26100)
  • Windows 11 25H2 (Build 26200)
  • Windows 11 26H1 (Build 28000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Windows 10, version 2104 (Build 20348)
  • Windows 11, version 22H2 (Build 22000)
  • Windows 11, version 24H2 (Build 26100)
  • Windows 11, version 25H2 (Build 26200)
  • Windows 11, version 26H1 (Build 28000)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

2026

Visual Studio Build Number

18.4.3

Device form factor

No response

Additional context

No response

Help us help you

Yes, but only if others can assist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions