question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. Create empty WPF project.
  2. Use property CacheMode=“BitmapCache” in MainWindow’s Grid;
  3. Show MainWindow on start application, then hide it. Show new MainWindow. You can use a code below. Additionally remove StartupUri in App.xaml
  4. 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:open
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
EZ64coolcommented, Aug 9, 2023

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 setting WindowStyle 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 using BitmapCache 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 file

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  <application>
    <!-- Windows 8 -->
    <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
  </application>
</compatibility>

I hope this helps someone out there, as it was a huge pain to find!

1reaction
Erapchucommented, Jul 7, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF rendering issue on any machine - Microsoft Q&A
WPF rendering issue on any machine · Create empty WPF project. · Use property CacheMode="BitmapCache" in MainWindow's Grid; · Show MainWindow on ...
Read more >
c# - WPF application render issue
I have a WPF application which somethimes behaves strange on different machines. This is the main screen of the application:.
Read more >
Weird Rendering Issues in WPF-Apps
A few weeks ago I started noticing that I have some weird rendering issues in all WPF-apps I use. Some parts of the...
Read more >
Video Rendering Issues for WPF Windows - Rick Strahl
While a bit late the party, this does not seem to be a rare issue. Apparently, the hardware rendering part is not properly...
Read more >
WPF window stops rendering when using a BitmapCache ...
Problem description: If a Window contains any UIElement with a BitmapCache and another window is hidden, the first Window will stop rendering ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found