Exception when attempting to show window after closing it via title bar
See original GitHub issueDescribe the bug
When running H.NotifyIcon.Apps.WinUI, after closing the window via the X icon in the title bar, attempting to show the window via the taskbar icon results in an exception.
Specifically, System.Runtime.InteropServices.COMException: 'The operation identifier is not valid. (0x800710DD)'
when accessing window.Visible
in ShowHideWindowCommand_ExecuteRequested
.
Steps to reproduce the bug
- Run H.NotifyIcon.Apps.WinUI
- Close the window via the title bar X icon
- Left click the taskbar icon or right click and select “show/hide window”
- Exception occurs
Expected behavior
The window should appear.
Screenshots
NuGet package version
No response
Platform
WinUI
IDE
Visual Studio 2022
Windows Version
Windows 11
WindowsAppSDK Version
1.2
WindowsAppSDK Type
Packaged
Manifest
No response
Additional context
No response
Issue Analytics
- State:
- Created 9 months ago
- Comments:5
Top Results From Across the Web
WPF: Cannot reuse window after it has been closed
When we try to show the Window which is closed, we will get the following exception. "Cannot set Visibility or call Show, ShowDialog, ......
Read more >Manage app windows (Windows App SDK)
Some of the benefits of using AppWindow (even when working with a UI framework) are: Easy title bar customization; which by default maintains ......
Read more >Python close window. close () method whenever we want ...
Show file. … The simplest way to close a window is to click the right (Windows) or left (macOS) 'X' button on the...
Read more >How to Make Frames (Main Windows)
A Frame is a top-level window with a title and a border. The size of the frame includes ... See Responding to Window-Closing...
Read more >How to Make Dialogs (The Java™ Tutorials > Creating ...
A Dialog window is an independent sub window meant to carry temporary notice apart from the main Swing Application Window. Most Dialogs present...
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 Free
Top 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
@myfix16
Use a DispatcherQueue to execute UI related code on the main UI thread. Otherwise you may get an exception.
I recommend using the CommunityToolkit.WinUI nuget package’s DispatcherQueueExtensions.EnqueueAsync.