WPF Rendering issue on any machine
See original GitHub issue- .NET Version: 5
- Windows version: Windows 10 20H2 (OS Build 19042.867)
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes, also .NET Framework 4.5.2, and all .NET Core versions.
Problem description: WPF windows stop rendering at all when use BitmapCache on any window’s control or root control and first shown WPF window was hidden by set Visibility to Hidden or call Hide() method.
Actual behavior: There’s no exceptions or fatal crashes. All WPF windows that use BitmapCache just stop rendering at all! While FIRST hidden window will not be shown.
Expected behavior: WPF Windows should render normally.
Minimal repro: Please follow this steps to catch problem on your machine or build any project below. Please, help me resolve it.
https://github.com/Erapchu/GhostWindows https://github.com/Erapchu/GhostWindowsCore
- Create empty WPF project.
- Use property CacheMode=“BitmapCache” in MainWindow’s Grid;
- Show MainWindow on start application, then hide it. Show new MainWindow. You can use a code below. Additionally remove StartupUri in App.xaml
- Press Ctrl + Alt + Del or Win + L and try to interact with showed window (resize, minimize) it should be broken now.
In App.xaml.cs OnStartup overrided method:
var window1 = new MainWindow(); window1.Show(); await Task.Delay(1000); window1.Hide(); var window2 = new MainWindow(); window2.Show();
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top GitHub Comments
Hey, we’ve been running into this issue for a while as well and have finally come to a stable (but not ideal) solution to this issue. When creating a window make sure to set
AllowsTransparency
to true (This will also require settingWindowStyle
to None meaning a custom style and Window class will be needed to add back the default windows functionality).I couldn’t tell you why this works unfortunately (but hopefully it can help narrow down the issue). I’ve tried setting
AllowsTransparency
on only windows usingBitmapCache
but it will still cause the problem unless all windows use it.It’s also worth noting that if you’re creating
WS_CHILD
window’s you’ll also need to set the minimum supported OS to windows 8 or higher inside the app.manifest fileI hope this helps someone out there, as it was a huge pain to find!
Setting up BitmapCache to root Grid of the window and Ctrl + Alt + Del invokes problem even if first window was showed, but not focused. When rendering suspended, WM_PAINT received by window in infinite loop. When remove BitmapCache, problem is vanished, until set it again. When hover mouse over very first window, ALL OTHER windows with BitmapCache rendering normally. Can anyone deep dive in that problem? @predavid @ryalanms develop branch was updated here - https://github.com/Erapchu/GhostWindows
Ghost windows video, behavior