This is a migrated thread and some comments may be shown as answers.

MainWindow "losts" focus after child RadWindow is closed

11 Answers 1687 Views
Window
This is a migrated thread and some comments may be shown as answers.
Zoltan
Top achievements
Rank 1
Zoltan asked on 24 Mar 2012, 03:14 PM
Hello,

I have a standard WPF MainWindow, from that I open a modal RadWindow (using .ShowDialog()). When the user clicks on one button I close the dialog and open a new non-modal RadWindow:

ConfigurationComparerWindow comparerWindow = new ConfigurationComparerWindow() { Owner = Application.Current.MainWindow, };
comparerWindow.Show();
//comparerWindow.Closed += (s, a) => { Application.Current.MainWindow.Focus(); };

This works just fine.

But if the user closes the second window I would expect that the MainWindow receives the focus. Instead the MainWindow is sent to back. If I uncomment the Closed event handler it works as I expected.

What is the preferred way of doing this?

Thanks,
   Zoltan

11 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 28 Mar 2012, 12:35 PM
Hello Zoltan,

This seems a bug in RadWindow for WPF which we will investigate and try to fix. For now, please use the workaround with Closed event handler - we've tested it and it worked as expected at our side as well.

Greetings,
Yana
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Missing User
answered on 26 Jun 2012, 06:13 PM
Hello,

I think I'm facing the same kind of situation, we have a MainWindow, from this main Window, we call the RadWindows, but sometimes, when we close the RadWindow, the App "lost" it's focus and the previous opened application show.

Ex:

Step 1: Programming in VS
Step 2: Start App
Step 3: Open RadWindow from App
Step 4: Close RadWindow
Step 5: Instead going back to the APP the "focus" goes to VS.

We thought this is some kind of VS bug, but when we put the App in production, the same behavior happened. Is there some kind of Know bug?

Thanks!
0
Missing User
answered on 26 Jun 2012, 08:10 PM
Searching on the internet I found this:

http://stackoverflow.com/questions/3144004/wpf-app-loses-completely-focus-on-window-close 

Seems that this is a "know" WPF problem.
0
Charles
Top achievements
Rank 1
answered on 28 Jul 2012, 11:49 PM
If I change my implementation to use Window instead of RadWindow, then the problem disappears.

For now I'm using the code below in the "Closed" event handler, which fixes it for now.  I'd be interested to know if the bug can be tracked down though...

var window = Owner as Window;
if (window != null)
{
   window.Activate();
}
0
Licensing
Top achievements
Rank 1
answered on 21 Nov 2013, 08:46 AM
Hello,

Is solution for this issue found? Or is it still being investigated?
0
Yana
Telerik team
answered on 26 Nov 2013, 11:48 AM
Hello,

This issue is logged in our internal backlog, but I am afraid that it is not fixed yet.  At the moment we cannot commit to any timeframe for fixing it.

I am sorry for the caused inconvenience.

Regards,
Yana
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
danparker276
Top achievements
Rank 2
answered on 03 Mar 2014, 11:03 PM
I think I'm facing the same issue.  When I close a showDialog radwindow and the try to focus on a textbox (on a content control on the mainpage ) it doesn't work.  If it's just a dialog() it works though.

If I use a regular window instead of a radwindow it's fine.

Is there a tracker on this?  Many of my users are keyboard data entry users who tab through everything.
0
Yana
Telerik team
answered on 07 Mar 2014, 08:15 AM
Hi Dan,

This looks like a different behavior than the previously discussed - in the described in this thread scenario the main Window is minimized when the dialog is closed . I would ask you to send us more details on your exact case, so we to be able to research it further.

Regards,
Yana
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Daniel B.
Top achievements
Rank 1
answered on 07 Jul 2015, 04:23 AM

@Yana, im seeing the issue described in the original thread (minimization of main window on show() OR showDialog() close via close button

 Im using UI for WPF, v2015.1.401.45 (Dev)

0
Nasko
Telerik team
answered on 09 Jul 2015, 08:08 AM
Hi,

The problem is caused by setting the Owner to MainWindow. The same behavior could be observed in the native WPF Window as well. What we could suggest you is to check the workarounds proposed by Zoltan and Charles in order to resolve the issue or to remove the Owner of the visualized RadWindow. Please, check the attached sample project that demonstrates how the Window behaves when there is set Owner and when there isn't.

Hopes this helps.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
karim
Top achievements
Rank 1
answered on 03 Aug 2016, 03:34 PM

Hello,

Try after secondWindow.close()

              firstWindow.TopMost=true;

and add after secondWindow.ShowDialog(firstWindow)

                      firstWindow.TopMost=false;

Tags
Window
Asked by
Zoltan
Top achievements
Rank 1
Answers by
Yana
Telerik team
Missing User
Charles
Top achievements
Rank 1
Licensing
Top achievements
Rank 1
danparker276
Top achievements
Rank 2
Daniel B.
Top achievements
Rank 1
Nasko
Telerik team
karim
Top achievements
Rank 1
Share this question
or