Changing Body text from within derived Appointment not updating

4 posts, 0 answers
  1. Micheal
    Micheal avatar
    5 posts
    Member since:
    Sep 2012

    Posted 25 Nov 2013 Link to this post

    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);
                    }
                }
            }


  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 26 Nov 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Micheal
    Micheal avatar
    5 posts
    Member since:
    Sep 2012

    Posted 26 Nov 2013 Link to this post

    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.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 27 Nov 2013 Link to this post

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