MainWindow "losts" focus after child RadWindow is closed

12 posts, 0 answers
  1. Zoltan
    Zoltan avatar
    7 posts
    Member since:
    Feb 2012

    Posted 24 Mar 2012 Link to this post

    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
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 28 Mar 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joao Paulo Grassi
    Joao Paulo Grassi avatar
    98 posts
    Member since:
    Feb 2011

    Posted 26 Jun 2012 Link to this post

    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!
  5. Joao Paulo Grassi
    Joao Paulo Grassi avatar
    98 posts
    Member since:
    Feb 2011

    Posted 26 Jun 2012 Link to this post

    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.
  6. Charles
    Charles avatar
    41 posts
    Member since:
    Mar 2012

    Posted 28 Jul 2012 Link to this post

    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();
    }
  7. Licensing
    Licensing avatar
    31 posts
    Member since:
    Sep 2011

    Posted 21 Nov 2013 Link to this post

    Hello,

    Is solution for this issue found? Or is it still being investigated?
  8. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 26 Nov 2013 Link to this post

    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 >>
  9. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 03 Mar 2014 Link to this post

    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.
  10. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 07 Mar 2014 Link to this post

    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!

  11. Daniel B.
    Daniel B. avatar
    18 posts
    Member since:
    Apr 2015

    Posted 06 Jul 2015 Link to this post

    @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)

  12. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 09 Jul 2015 Link to this post

    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
  13. karim
    karim avatar
    1 posts
    Member since:
    Aug 2016

    Posted 03 Aug Link to this post

    Hello,

    Try after secondWindow.close()

                  firstWindow.TopMost=true;

    and add after secondWindow.ShowDialog(firstWindow)

                          firstWindow.TopMost=false;

Back to Top
UI for WPF is Visual Studio 2017 Ready