Wrong binding on appointment template when adding/editing appointments

4 posts, 0 answers
  1. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 04 Oct 2011 Link to this post

    I'm using custom appointments in a grouped schedule view, with a custom template where the background color depends on properties from the custom appointments. It works fine, however when i create / edit appointments, the background color changes incorrectly without passing through the converter.

    Here is the AppointmentTemplate i use
    <DataTemplate x:Key="PlanificationTemplate">
               <Border Background="{Binding Converter={StaticResource PrestationTypeConverter}}">
                   <StackPanel>
                       <StackPanel Orientation="Horizontal">
                           <TextBlock Text="{Binding Subject}" FontWeight="Bold" TextWrapping="Wrap" />
                           <TextBlock FontWeight="Bold"> - (</TextBlock>
                           <TextBlock Text="{Binding Appointment.Planification.Prestation.Produit}" FontWeight="Bold" TextWrapping="Wrap" />
                           <TextBlock FontWeight="Bold">)</TextBlock>
                       </StackPanel>
                       <StackPanel Orientation="Horizontal">
                           <TextBlock>Site: </TextBlock>
                           <TextBlock Text="{Binding Appointment.Planification.Prestation.Site}" FontWeight="Bold" TextWrapping="Wrap" />
                       </StackPanel>
                       <StackPanel Orientation="Horizontal">
                           <TextBlock>De </TextBlock>
                           <TextBlock Text="{Binding Start, StringFormat=\{0:HH:mm\}}" TextWrapping="Wrap" />
                           <TextBlock> à </TextBlock>
                           <TextBlock Text="{Binding End, StringFormat=\{0:HH:mm\}}" TextWrapping="Wrap" />
                       </StackPanel>
                   </StackPanel>
                    
               </Border>
           </DataTemplate>
    And the corresponding converter

    public class PrestationTypeConverter: IValueConverter
       {
           public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {
               PlanificationAppointment v = null;
               var vaip = value as AppointmentItemProxy;
               if (vaip != null)
               {
                   v = vaip.Appointment as PlanificationAppointment;
               }
               else
               {
                   v = value as PlanificationAppointment;
               }
     
                
               if (v != null)
               {
                   return ConvertPrestationTypeToColor.Convert(v.Planification.Prestation); // this is a Dictionnary type -> color
               }
               else
               {
                   return new SolidColorBrush(Color.FromArgb(255, 42, 156, 24));
               }
           }
     
           public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {
               throw new NotImplementedException();
           }
       }

    When i create an appointment, the converter seems to receive in its value the rightmost appointment (at least that's what it looks like)

    I have uploaded a flv movie of the behavior here: http://api.ge.tt/0/9XB2KQ8/0/blob/download
    It would have been nice to upload it on your forums but even changing the extension didn't work :)
  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 05 Oct 2011 Link to this post

    Hi Samy,

    We will be happy to help you, but the provided information is not enough to reproduce the problem. I suggest you open a support thread and send us sample running project including the custom appointment implementation that we can test locally. We will review it and provide you with more details.

    Greetings,
    Rosi
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 05 Oct 2011 Link to this post

    I reproduced the problem in a sample project which is included in the support ticket #470489
  5. Aymen
    Aymen avatar
    1 posts
    Member since:
    Jul 2012

    Posted 05 Jul 2013 Link to this post

    Hi,
    I have the same problem, 
    it is simple to reproduce it
    In this EditAppointementTemplate i create two textBox of Subject, when u write in one textbox u have not the same value in the second
    => so there is not a correct binding
    Please try to use this style in standard  RadScheduleView
    thanks,
    --
    <ControlTemplate x:Key="EditAppointmentTemplate" TargetType="telerik:SchedulerDialog">
              <StackPanel>
                    <TextBlock  telerik:LocalizationManager.ResourceKey="Title" />
                   <TextBox IsReadOnly="False" Text="{Binding Occurrence.Appointment.Subject,Mode=TwoWay}" />
      <TextBox IsReadOnly="False" Text="{Binding Occurrence.Appointment.Subject,Mode=TwoWay}" />
    <StackPanel>
     </ControlTemplate>

     <Style x:Key="EditAppointmentDialogStyle" TargetType="telerik:SchedulerDialog">            
                <Setter Property="Template" Value="{StaticResource EditAppointmentTemplate}" />
    </Setter>
     </Style>








Back to Top