Search code examples
c#wpffullscreen

WPF application doesn't draw correctly when another application is running in fullscreen


My application is a bit more complicated than the following, but I've distilled the problem to a simple case.

I have a textbox bound to an object's property. The binding works fine when working from inside the app.

My application runs a TCP server in another thread that receives messages from a mod I've created for a game (the game is Binding of Isaac, if that's any help). The mod sends messages to my application when the user presses a key in-game. When the server receives a message, it invokes a change in the bound property through the app's dispatcher, like so:

App.Current.Dispatcher.Invoke(delegate
{
    TestModel.Number = sum;
});

This works fine when the game is windowed; the textbox is updated according to the message and drawn correctly. When the game is in fullscreen, however, and I alt-tab back to my application after sending the message, the textbox text doesn't update until I mouse-over. I'm pretty certain that the text value of the textbox is updated correctly, but it just isn't redrawn while the game is fullscreen, and mousing over triggers a redraw.

Strangely, within the first 10 or so seconds of starting my application, the textbox updates correctly even when the game is fullscreened. After that, the issue starts up.

I would greatly appreciate any insight or solutions.


Solution

  • Likely a driver problem. Try disabling hardware acceleration on startup:

    RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
    

    Performance will suffer, but it should render properly.