Cancel editing

3 posts, 0 answers
  1. Rieni De Rijke
    Rieni De Rijke avatar
    170 posts
    Member since:
    Mar 2010

    Posted 29 Oct 2013 Link to this post

    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. Rieni De Rijke
    Rieni De Rijke avatar
    170 posts
    Member since:
    Mar 2010

    Posted 29 Oct 2013 Link to this post

    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();
                
            }
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 30 Oct 2013 Link to this post

    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 >>
Back to Top