How to prevent a new WPF form from stealing focus?

后端 未结 3 1790
清歌不尽
清歌不尽 2020-12-03 10:07

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 backgrou

相关标签:
3条回答
  • 2020-12-03 10:35

    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!

    0 讨论(0)
  • 2020-12-03 10:44

    In my application I need to show a notification Window on top of all other windows while my MainWindow is minimized, but without stealing the focus.

    So I just do this:

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        this.Topmost = true;
        this.Topmost = false;
    }
    
    0 讨论(0)
  • 2020-12-03 10:55

    You could set the Focusable property of the window to false.

    0 讨论(0)
提交回复
热议问题