Skip to content

TabView throws ArgumentException when TabViewItem has no effective header #6100

@xm-i

Description

@xm-i

Describe the bug

TabView throws an unhandled ArgumentException (E_INVALIDARG) when a TabViewItem
has no effective header value while containing child content.

The exception occurs when TabViewItem.Header is not set at all, or when it is
bound to an empty string. Binding a non-empty string avoids the issue.

This exception originates from WinUI/WinRT and is surfaced via
Microsoft.UI.Xaml.UnhandledException.

Steps to reproduce the bug

  1. Create a new WinUI 3 (Desktop) project
  2. Add a TabView using TabItemsSource and TabItemTemplate
  3. Define a TabViewItem that contains child content
  4. Do not set TabViewItem.Header, or bind it to an empty string
  5. Run the application
  6. An unhandled ArgumentException is raised

XAML

<TabView TabItemsSource="{x:Bind Items}">
    <TabView.TabItemTemplate>
        <DataTemplate>
            <TabViewItem>
                <Grid />
            </TabViewItem>
        </DataTemplate>
    </TabView.TabItemTemplate>
</TabView>

Code Behind

public ObservableCollection<string> Items { get; } = [""];

Expected behavior

TabView should handle TabViewItem instances with no header value gracefully,
or reject them with a clear and documented error.

An empty or unset header should not cause an unhandled exception.

Screenshots

No response

NuGet package version

Windows App SDK 1.8.3: 1.8.251106002

Packaging type

Unpackaged, Packaged (MSIX)

Windows version

Windows 11 version 24H2 (26100, June 2025 Update)

IDE

Other

Additional context

IDE:
Microsoft Visual Studio Professional
December 2025 Feature Update
Channel: Stable
Version: 18.1.0

Exception details:

  • Exception type: System.ArgumentException

  • HRESULT: 0x80070057 (E_INVALIDARG)

  • Message:
    "The parameter is incorrect.

    The parameter is incorrect."

  • ParamName: null

  • InnerException: null

  • StackTrace: null

Additional observations:

  • The exception occurs even if TabViewItem.Header is not bound at all.
  • Binding an empty string ("") produces the same result.
  • Binding a non-empty string (e.g. "a") avoids the exception.
  • If TabViewItem contains no child content, the exception does not occur,
    even when the header is missing or empty.

Workaround:
Ensure that TabViewItem.Header always has a non-empty value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions