microsoft / microsoft/microsoft-ui-xaml
TabView throws ArgumentException when TabViewItem has no effective header
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### 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
```XAML
```
Code Behind
```csharp
public ObservableCollection 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.
Contributor guide
Research direction
Start by reproducing the supplied WinUI 3 Desktop XAML example with an empty Items value and child content in TabViewItem. Investigate the TabView and TabViewItem handling involved in that reproduction; done means missing or empty headers no longer produce an unhandled ArgumentException while non-empty headers continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100