This repository was archived by the owner on Aug 30, 2023. It is now read-only.
  
  
  - 
                Notifications
    You must be signed in to change notification settings 
- Fork 92
    This repository was archived by the owner on Aug 30, 2023. It is now read-only.
  
  
XAML Island doesn't respond to Windows app themes changes (Dark, Light) at run-time #228
Copy link
Copy link
Closed
Labels
WinUI3_revisitThis issue should be revisited when WinUI 3 Islands is availableThis issue should be revisited when WinUI 3 Islands is availableXamlIslands 🏝️bug 🐛Something isn't workingSomething isn't working
Description
Describe the bug
I have no idea if this issue should go here (or to Microsoft.Toolkit.Win32), but since the source code is here, I post it here.
I'm using XamlIsland in WPF to host my UWP custom control.
However it occasionally crash with InvalidOperationException says something like "Cannot create new view because main window is not created." (the actual message is "無法建立新的檢視,因為尚未建立主視窗", this is just a translation.)
with a stacktrace:
   at Windows.ApplicationModel.Core.CoreApplication.get_MainView()
   at Microsoft.Toolkit.Uwp.UI.Helpers.ThemeListener.Settings_ColorValuesChanged(UISettings sender, Object args) in D:\a\1\s\Microsoft.Toolkit.Uwp.UI\Helpers\ThemeListener.cs:line 81
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
I haven't switch the theme, tho... I just leave it there running for several minute and it crashes.
- Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:
Steps to Reproduce
Steps to reproduce the behavior:
- follow the WPF XamlIsland tutorial on Microsoft website
- run the program and wait
Expected behavior
no problem
Screenshots
probably don't need one...
Environment
NuGet Package(s):
<ItemGroup>
  <PackageReference Include="Microsoft.Toolkit.UI.XamlHost" Version="6.0.0" />
  <PackageReference Include="Microsoft.Toolkit.Wpf.UI.XamlHost" Version="6.0.0" />
</ItemGroup>
Package Version(s): 6.0.0
Windows 10 Build Number:
- Fall Creators Update (16299)
- April 2018 Update (17134)
- October 2018 Update (17763)
- May 2019 Update (18362)
- Insider Build (build number: 18363.535)
App min and target version:
- Fall Creators Update (16299)
- April 2018 Update (17134)
- October 2018 Update (17763)
- May 2019 Update (18362)
- Insider Build (xxxxx)
Device form factor:
- Desktop
- Xbox
- Surface Hub
- IoT
Visual Studio
- 2017 (version: )
- 2019 (version: )
- 2019 Preview (version: 16.5.0)
Additional context
currently no
Metadata
Metadata
Assignees
Labels
WinUI3_revisitThis issue should be revisited when WinUI 3 Islands is availableThis issue should be revisited when WinUI 3 Islands is availableXamlIslands 🏝️bug 🐛Something isn't workingSomething isn't working