I have written a simple MSN-style program that will send and retrieve messages using WCF. The main form contains a Textbox to type in the message to be sent. In the background the application polls the server every few seconds for new messages. When a new message is received a new window is opened to display it. This has to be done on the UI thread using the Dispatcher class.
The problem is that when the new window is shown, the focus shifts away from the TextBox, so that typing is interrupted. This is very annoying! In MSN Messenger it is possible to continue typing your own message while receiving one. How is it done?
As a workaround I postpone the popup with the new message while the TextBox has focus, but there should be a better way!
The answer is simple: Since .NET 3.5 SP1 WPF forms have a ShowActivated
property. Set this to false and any form thus marked won't steal no focus no more!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With