focus - ALT-TAB always activates main window in WPF app with multiple owned windows -


on windows 7, .net 4.0 have problem can reproduced copying following code blank wpf application generated visual studio:

    public mainwindow()     {         initializecomponent();         loaded += new routedeventhandler(mainwindow_loaded);     }      void mainwindow_loaded(object sender, routedeventargs e)     {         new window() { title = "test", showintaskbar = false, owner = }.show();     } 
  1. run app
  2. activate secondary window
  3. alt-tab other running application
  4. use mouse activate our wpf app in taskbar

now wpf app active again, secondary window activated , main window deactivated, expected (and desired) behavior.

now instead (only step 4 differs):

  1. run app
  2. activate secondary window
  3. alt-tab other running application
  4. alt-tab our wpf app

the wpf app active again, main window activated. adding code

private void application_activated(object sender, eventargs e) {     windows[1].activate(); } 

to app.xaml.cs not solve problem because in second case both windows activated. also, clicking secondary window not deactivate main window. have click (already activated) main window , secondary window again achieve this.

how can avoid (only secondary window should active in both cases)?

codeproject addresses issue here, hope you're looking for.

combine post tamil khason , in theory can override onfocus event on global level every time window on focus, becomes "main window" target of alt+tab.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -