Skip to content

WrapPanel with infinity width crashes trying to stretch its last item #703

Closed

Description

@AndrewKeepCoding

Describe the bug

This works:

<Grid ColumnDefinitions="*">
    <toolkit:WrapPanel StretchChild="Last">
        <Button />
    </toolkit:WrapPanel>
</Grid>

but this throws System.Runtime.InteropServices.COMException.

<Grid ColumnDefinitions="Auto">
    <toolkit:WrapPanel StretchChild="Last">
        <Button />
    </toolkit:WrapPanel>
</Grid>

Steps to reproduce

Use the code above.

Expected behavior

Works without throwing exceptions.

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)
  • Other (specify)

Other Windows Build number

Windows 11 24H2 (Build 26100.4652)

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)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item.

Activity

  1. AndrewKeepCoding commented on Jul 17, 2025

    @AndrewKeepCoding
    MemberAuthor

    This bug is causing the crash in #297.

  2. added this to the 8.3 milestone on Jul 17, 2025
  3. Jay-o-Way commented on Jul 24, 2025

    @Jay-o-Way

    ⚠️
    Hey @AndrewKeepCoding, I see you use the term "infinite width", but * doesn't mean "infinite". It means "stretch using equal space" and that can be seen by something like <Grid ColumnDefinitions="1*, 3*">. This means: the second column must be three times the size of the first. In other words: two columns, 25% and 75% width of the total. When you have only one column, and one child element, that means the Grid is stretched horizontally, so the child is actually correctly stretching its last item.

  4. moved this to 🆕 New in Toolkit 8.xon Aug 7, 2025
  5. added
    components::controls::primitivesPrimitive layout controls such as SwitchPresenter, UniformGrid, WrapLayout, StaggeredPanel, etc.
    on Aug 7, 2025
  6. moved this from 🆕 New to ✅ Done in Toolkit 8.xon Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponents::controls::primitivesPrimitive layout controls such as SwitchPresenter, UniformGrid, WrapLayout, StaggeredPanel, etc.

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions