Cancel closing RadWindow.Confirm(...)

3 posts, 1 answers
  1. Sandi Markon
    Sandi Markon avatar
    101 posts
    Member since:
    Jul 2012

    Posted 26 Feb 2015 Link to this post

    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. Answer
    Polya
    Admin
    Polya avatar
    199 posts

    Posted 02 Mar 2015 Link to this post

    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.

     
  3. DevCraft banner
  4. Sandi Markon
    Sandi Markon avatar
    101 posts
    Member since:
    Jul 2012

    Posted 04 Mar 2015 in reply to Polya Link to this post

    This works, thanks.
Back to Top