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

Cancel closing RadWindow.Confirm(...)

2 Answers 112 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sandi Markon
Top achievements
Rank 1
Sandi Markon asked on 26 Feb 2015, 08:12 AM
We use RadWindow in this way (from command in ViewModel):

RadWindow.Confirm(new DialogParameters{
  Content = new ContentPresenter {ContentTemplate = Template("SomeTemplateFromXamlWithTextBoxAndComboBox")},
  Closed = (o, e) => {
    if (there are some errors) return;
    do stuff if there are no errors
  }
});

In the end, windows is closed. But what we want is if there are errors, user should be notified with MessageBox and then RadWindow should remain open.

There is no "PreviewClosed" in RadWindow.Confirmed. We tried a simple RadWindow but then we would have to define our own buttons and we have problems binding events to them.

How could we achieve the desired behavior?

2 Answers, 1 is accepted

Sort by
0
Accepted
Polya
Telerik team
answered on 02 Mar 2015, 02:53 PM
Hi Sandi Markon,

I suggest calling Show() or ShowDialog() to the confirm window if the criteria for pass is false:
if (e.DialogResult == true)
{
    if (this.txtBlock.Text == "AAA")
    {
        // do something
    }
    else
    {
        var confirmWindow = sender as RadWindow;
        confirmWindow.Closed -= OnConfirmClosed;
        confirmWindow.Closed += OnConfirmClosed;
        confirmWindow.ShowDialog();
    }
}

I've prepared a sample project demonstrating this approach. Please find it attached.
Hopefully this helps and is suitable for your scenario.

Regards,
Polya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sandi Markon
Top achievements
Rank 1
answered on 04 Mar 2015, 08:09 AM
This works, thanks.
Tags
Window
Asked by
Sandi Markon
Top achievements
Rank 1
Answers by
Polya
Telerik team
Sandi Markon
Top achievements
Rank 1
Share this question
or