CommunityToolkit / CommunityToolkit/Windows
Segmented Control in WPF XAML ISLAND, XAML parsing failed.
- Dominant language
- C#
- Stars
- 1.1k
- Forks
- 166
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
Hello,
When I add
```xmlns:controls="using:CommunityToolkit.WinUI.Controls"```
And
```
```
To StackPanel, the Window does not initialize anymore with cryptic error: XAML parsing failed.
I think the issue is how I initialize resources:
```
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
XamlControlsXamlMetaDataProvider.Initialize();
xamlMetaDataProvider = new();
this.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.Controls.XamlControlsResources());
//this.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.ResourceDictionary() { Source = new Uri("ms-appx:///CommunityToolkit.WinUI.Controls.Segmented/Themes/Generic.xaml") });
}
```
If I uncomment my attempt to load Segmented, it fails on COM Exception.
### Steps to reproduce
https://github.com/castorix/WPF_XAML_Islands_WinUI3/tree/master
Clone this repo, update to newest WinUI SDK, add CommunityToolkit.WinUI.Segmented and add Segmented. Same issue.
### Expected behavior
Segmented loads?
### Screenshots
_No response_
### Code Platform
- [ ] UWP
- [x] 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)
- [x] Windows 10 22H2 (Build 19045)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] 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)
- [x] 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
2026 Version: 18.0.0
### Device form factor
Desktop
### Additional context
It is WPF XAML ISLANDS.
### Help us help you
Yes, I'd like to be assigned to work on this item.
Contributor guide
Assessment
This issue has not been assessed yet.