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

Cancel editing

2 Answers 12 Views
This is a migrated thread and some comments may be shown as answers.
Rieni De Rijke
Top achievements
Rank 1
Rieni De Rijke asked on 29 Oct 2013, 12:14 PM
How can we prevent that the editdialog is showing?

This does not work:

        private void ScheduleView_OnAppointmentEditing(object sender, AppointmentEditingEventArgs e)
        {
            //....
            
           e.Cancel = true;
           e.Handled = true;
        }

2 Answers, 1 is accepted

Sort by
0
Rieni De Rijke
Top achievements
Rank 1
answered on 29 Oct 2013, 02:08 PM
Ok, I see that I should use this:

    private void ScheduleView_OnShowDialog(object sender, ShowDialogEventArgs e)
    {
       if ((e.DialogViewModel is AppointmentDialogViewModel))
       {
           e.Cancel = true;
       }
    }

So far, so good.
But when I use this, the OnShowDialog runs twice...

        private void ScheduleView_OnShowDialog(object sender, ShowDialogEventArgs e)
        {
            if ((e.DialogViewModel is AppointmentDialogViewModel))
            {
                e.Cancel = true;
                GoConfirm();
            }
        }

        private void Confirm()
        {
            var appointment = scheduleView.SelectedAppointment as IAppointment;
            if (appointment == null) return;
            
            scheduleView.BeginEdit(appointment);
            appointment.Subject = "Confirmed";
            scheduleView.Commit();
            
        }
0
Kalin
Telerik team
answered on 30 Oct 2013, 07:50 AM
Hi Rieni,

What I can suggest you is to call the Confirm method through Dispatcher, this way you will avoid the explained behavior. Please try the code snippet below:

private void ScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
{
    if ((e.DialogViewModel is AppointmentDialogViewModel))
    {
        e.Cancel = true;
        this.Dispatcher.BeginInvoke(new Action(Confirm));
    }
}

Hope this helps.

Regards,
Kalin
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 >>
Asked by
Rieni De Rijke
Top achievements
Rank 1
Answers by
Rieni De Rijke
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or