Windows
Windows copied to clipboard
Segmented Control in WPF XAML ISLAND, XAML parsing failed.
Describe the bug
Hello,
When I add
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
And
<controls:Segmented>
</controls:Segmented>
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.