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

Make RadWindow minimize/maximize/close take precedence

3 Answers 206 Views
Window
This is a migrated thread and some comments may be shown as answers.
CyberBotX
Top achievements
Rank 2
Veteran
CyberBotX asked on 03 Apr 2020, 07:20 PM

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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 08 Apr 2020, 03:10 PM

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.
0
CyberBotX
Top achievements
Rank 2
Veteran
answered on 08 Apr 2020, 03:34 PM

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.

0
Vladimir Stoyanov
Telerik team
answered on 13 Apr 2020, 09:25 AM

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.
Tags
Window
Asked by
CyberBotX
Top achievements
Rank 2
Veteran
Answers by
Vladimir Stoyanov
Telerik team
CyberBotX
Top achievements
Rank 2
Veteran
Share this question
or