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

Wrong binding on appointment template when adding/editing appointments

3 Answers 53 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
samy
Top achievements
Rank 1
samy asked on 04 Oct 2011, 01:20 PM
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 :)

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 05 Oct 2011, 08:01 AM
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 >>

0
samy
Top achievements
Rank 1
answered on 05 Oct 2011, 08:44 AM
I reproduced the problem in a sample project which is included in the support ticket #470489
0
Aymen
Top achievements
Rank 1
answered on 05 Jul 2013, 11:31 AM
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>








Tags
ScheduleView
Asked by
samy
Top achievements
Rank 1
Answers by
Rosi
Telerik team
samy
Top achievements
Rank 1
Aymen
Top achievements
Rank 1
Share this question
or