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(); }
- run app
- activate secondary window
- alt-tab other running application
- 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):
- run app
- activate secondary window
- alt-tab other running application
- 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
Post a Comment