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

Changing Body text from within derived Appointment not updating

3 Answers 75 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Micheal
Top achievements
Rank 1
Micheal asked on 25 Nov 2013, 06:05 AM
I have derived a custom appointment that implements IAppointment called AppointmentViewModel. I have created a customized EditAppointmentView Dialog, by taking the provided RadSchedulView template XAML and adding a few RadComboBoxes (that are not resources), and assigning the template to the RadScheduleView's EditAppointmentDialogStyle. After a bit of work, all is working as planned except for one problem. In our LOB app, the schedule represents appointments in a auto repair shop. We need to provide the user with a list of predefined repair symptoms that they can choose from when creating or editing the appointment. I have successfully added a RadComboBox to allow them to choose from the list of symptoms. After making a selection in the RadComboBox, I call code on the SelectedItem's setter, that calls an internal method on my derived Appointment to concatenate the selected symptom text to the Body property of the Appointment. All works, the RadComboBox, the concatenation code, everything, except the Body TextBox will not show the value stored for the Body until the Appointment is closed and reopened. I am calling OnPropertyChanged(() => Body)  both in the method that appends the symptom to the Body and on the Body setter itself. All seem to be ignored. I know about having to BeginEdit and CommitEdit the RadScheduleView when updating appointments with code and need the ScheduleView to update, but shouldn't the IAppointment behind the EditAppointmentView Dialog be able to edit one of it's own properties and have it be reflected in the open Edit Dialog if it is a TwoWay binding? Originally I didn't have the Body overridden in my derived Appointment, but did so later just to confirm the firing of the OnPropertyChanged.

Once again, the desired work is taking place and upon close and reopen the Body shows the appended symptom as desired, but not live when you make the change.  Am I missing something?

XAML snippet from customized EditAppointmentTemplate for Body TexyBox;

<TextBox
   Grid.Row="1"
   HorizontalAlignment="Stretch
   Margin="8,11,12,8"
   VerticalAlignment="Stretch"
   TextWrapping="WrapWithOverflow"
   VerticalScrollBarVisibility="Auto"
   HorizontalScrollBarVisibility="Auto"
   SpellCheck.IsEnabled="True"
   Text="{Binding Occurrence.Appointment.Body, Mode=TwoWay}"
   AcceptsReturn="True"
   AcceptsTab="True"
   IsReadOnly="{Binding IsReadOnly}"
/>

Property in my derived IAppointment that the Body TextBox is bound too;
 public override string Body
 {
     get
     {
         return base.Body;
     }
     set
     {
         base.Body = value;
         OnPropertyChanged(() => Body);
     }
 }

For what it's worth, here's the little method that is called to concatenate a string to the Body property. Note that I have tried calling OnPropertyChanged(() => Body) in this method as well, but currently have to commented out. The OnPropertyChanged(() => Body) of the Body itself is being fired.

        internal void AppendSymptomToAppointmentNote()
        {
            if (SelectedSymptom == null)
                return;         

            if (Body == null)
            {
                Body = "* " + SelectedSymptom + "\r\n";
//                OnPropertyChanged(() => Body);
            }
            else
            {
                if (!Body.Contains(SelectedSymptom))
                {
                    Body = Body + "* " + SelectedSymptom + "\r\n";
//                    OnPropertyChanged(() => Body);
                }
            }
        }


3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 26 Nov 2013, 09:05 AM
Hi Michael,

Actually this is expected behavior - when EditAppointmentDialog is shown,  updating the appointment properties with code does not notify the UI. It is implemented like this for optimization purposes. However, you can work-around this behavior by using the approach suggested in the following Code Library:
http://www.telerik.com/community/code-library/wpf/scheduleview/how-to-create-advanced-custom-editapointmentdialog.aspx

I hope this helps.
,
Regards,
Yana
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 >>
0
Micheal
Top achievements
Rank 1
answered on 26 Nov 2013, 10:26 PM
Thank you Yana,

This was not the news I had hoped for, but I appreciate the response and the example in the Code Library.

Using the sample project I was able to accomplish what I needed today in short order. In fact, I needed to update the appointment duration on the Edit Appointment Dialog just like the sample project did, so I was able to cut and past that part verbatim!

Thanks again.
0
Yana
Telerik team
answered on 27 Nov 2013, 08:25 AM
Hi Michael,

I am glad to hear the Code Library project helped.

Regards,
Yana
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 >>
Tags
ScheduleView
Asked by
Micheal
Top achievements
Rank 1
Answers by
Yana
Telerik team
Micheal
Top achievements
Rank 1
Share this question
or