Skip to content

Segmented Control crash if StackPanel Orientation value is Horizontal #425

@WillyWoe

Description

@WillyWoe

Describe the bug

If StackPanel Orientation value is set to Vertical it works, but if is set to Horizontal the app crashes:

Xaml

<Window
    x:Class="LabsTests.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:LabsTests"
    xmlns:labs="using:CommunityToolkit.Labs.WinUI"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Orientation="Vertical"> <!--If Orientation value is Horizontal, the app crashes-->
        <labs:Segmented SelectedIndex="0"                        
                        SelectionMode="Single">
            <labs:SegmentedItem Content="Item 1">
                <labs:SegmentedItem.Icon>
                    <FontIcon Glyph="&#xEA3A;" />
                </labs:SegmentedItem.Icon>
            </labs:SegmentedItem>
            <labs:SegmentedItem Content="Item 2">
                <labs:SegmentedItem.Icon>
                    <FontIcon Glyph="&#xEA3A;" />
                </labs:SegmentedItem.Icon>
            </labs:SegmentedItem>
            <labs:SegmentedItem Content="Item 3 with a long label">
                <labs:SegmentedItem.Icon>
                    <FontIcon Glyph="&#xEA3A;" />
                </labs:SegmentedItem.Icon>
            </labs:SegmentedItem>
            <labs:SegmentedItem Content="Item 4">
                <labs:SegmentedItem.Icon>
                    <FontIcon Glyph="&#xEA3A;" />
                </labs:SegmentedItem.Icon>
            </labs:SegmentedItem>
        </labs:Segmented>
    </StackPanel>
</Window>

NuGet references

<PackageReference Include="CommunityToolkit.Labs.WinUI.SegmentedControl" Version="0.0.2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.1" />

Steps to reproduce

1. Create a new WinUI Desktop project.
3. Copy the xml above and use the NuGet references.
4. Set `StackPanel` Orientation value to Horizontal in the example above.
5. Run the app.

Expected behavior

Segmented Control should not crash if StackPanel Orientation is set to Horizontal.

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 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

Windows 10 22H2 Build 19045

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

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Additional context

No response

Help us help you

No, I'm unable to contribute a solution.

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't workingexperiment 🧪Used to track issues that are experiments (or their linked discussions)issue 🧪Used for tracking an Issue/Bug/Feature of an open Experiment/Component

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions