ecnepsnai
ecnepsnai

Reputation: 2026

Stop notification window from stealing focus

In my WPF application I have a notification window that appears at the top right for 3 seconds and closes. Just a normal notification window.

But when it appears, it takes the focus away from any window that was active. For example, if I'm typing in Chrome and the window appears, chrome looses focus and my typing is halted.

The notification window is set to top most so that it will appear on top of other windows, but how do I go about stopping it from stealing the focus of the user?

Upvotes: 1

Views: 979

Answers (1)

Bojin Li
Bojin Li

Reputation: 5799

Set Window.ShowActivated Property to false on your notification window.

var notificationWindow= new NotificationWindow{
    ShowActivated = false, Topmost = true, ShowInTaskbar = false};
notificationWindow.Show();

Upvotes: 3

Related Questions