Unhandled exception on popup open
See original GitHub issueDescribe the bug
Such a code causes an unhandled exception
Steps to reproduce the bug
- Create a blank WinUI app for desktop
- Add the following code in MainWindow constructor after InitializeComponent.
var p = new Popup();
p.Child = new TextBlock() { Text = "Text" };
p.IsOpen = true;
- Run application
Version Info
Windows 10 1903 (OS Build 18362.1082)
NuGet package version:
WinUI 3.0.0-preview2.200713.0
Windows app type:
UWP | Win32 |
---|---|
Yes |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
c# - Exception unhandled popup
Open the Exception settings window (Under Debugger->Windows) and add a checkbox next to "Common language exceptions". This now might show some ...
Read more >How to Fix the "Unhandled Exception Has Occurred in ...
If your apps have issues running, here's how to fix unhandled exceptions on Windows.
Read more >Unhandled exception popup font - Developer Community
I got it. The exception popup uses Environment font. But text in it uses OTHER rendering than solution explorer and ALL other VS2017...
Read more >Manage exceptions with the debugger in Visual Studio
In the Exception Settings window, open the shortcut menu by right-clicking a column label, and then select Show Columns > Additional Actions. ( ......
Read more >Unhandled exception popup when try to open Ranorex ...
I try to edit my old recording. When click save, it pop up exception "Error while saving" . After a few times click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error message shown in the output window is “explaining” the error, but we should definitely make some improvements to better expose the error (rather than just seeing the E_UNEXPECTED message in the exception dialog), better explain what needs to be done, and better document this issue.
The problem is that this is a parentless popup, so XAML doesn’t know which window to show the popup for. (And it complains even when there is only one to prevent weird behavior of having code stop working when there is more than one window.) There are two possible fixes to this: (1) add the Popup in the Children list of some other element, or (2) set the XamlRoot property to explicitly state what the popup belongs to.
Option (2) provides a trivial fix in your example by adding the second line here:
Note: The XamlRoot needs to be set before setting the popup to IsOpen=true.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.