Make RadWindow minimize/maximize/close take precedence

4 posts, 1 answers
  1. CyberBotX
    CyberBotX avatar
    11 posts
    Member since:
    Nov 2016

    Posted 03 Apr 2020 Link to this post

    I've noticed that if I have a child of a RadWindow that is currently in a validation error state, I cannot utilize the RadWindow's minimize, maximize or close buttons.

    For example, a RadGridView with items that implement INotifyDataErrorInfo, when a new item is added, the new item's fields are invalid, but I cannot click the RadWindow's buttons unless I cancel out of the new row.

    In addition, when adding debugging output to the events for the RadGridView's events, I've found that if I am in the middle of an edit in a cell, clicking any of the RadWindow's buttons causes it to fire the events for the cell and row edits ending prior to firing any of the RadWindow's events, such as clicking the close button fires the PreviewClosing event after the RadGridView's events.

    Is there a way to give precedence to the RadWindow's buttons so they can be utilized regardless of the state of controls within the window and to run their events prior to controls in the RadWindow?

  2. Answer
    Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    720 posts

    Posted 08 Apr 2020 Link to this post

    Hello Naram,

    Thank you for the shared information.

    What I can suggest in order to achieve the desired behavior is to handle the PreviewMouseLeftButtonDown event of the window. Here is what I have in mind:

    private void Window_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
            {
                var button = (e.OriginalSource as DependencyObject).ParentOfType<RadButton>();
    
                if(button != null && button.Name == "PART_CloseButton")
                {
                    // close window
                }
            }

    Do give this approach a try and let me know how it goes.

    Regards,
    Vladimir Stoyanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. CyberBotX
    CyberBotX avatar
    11 posts
    Member since:
    Nov 2016

    Posted 08 Apr 2020 in reply to Vladimir Stoyanov Link to this post

    That seems to work to a degree. It does let me close the window, but some of the other events for the RadGridView still fire after the window is closed, such as the CellValidating event. Although I could probably work around that with a variable to prevent it from doing anything.

    I was able to use that to successfully make the minimize/maximize/restore buttons function as well. The issue with the CellValidating event, though, only happens on closing the window. I'm calling the Close() method of the RadWindow, unless there is a better way.

  4. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    720 posts

    Posted 13 Apr 2020 Link to this post

    Hello Naram,

    Indeed using the Close method is the way to go. In that case the RadGridView will evaluate the validation and you can introduce some logic to skip the CellValidating event as you mentioned. I do hope that you will find this approach applicable for your scenario. 

    Regards,
    Vladimir Stoyanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top