ItemTemplate animation bug

1 posts, 0 answers
  1. Oleg
    Oleg avatar
    42 posts
    Member since:
    Oct 2011

    Posted 02 Nov 2011 Link to this post

    Hello Telerik team!
    As I've already posted here:
    I want to animate the creation of an Appointment. I did it through the "ItemTemplate" and "Loaded" event (see code below)

    The problem is (looks like a bug), that the DataContext of the ItemTemplate is always the last Appointment of the Collection (in the UI-order).
    This means - if I create a new appointment below all others, the DataContext is the created appointment and I can animate it (correct behavior)
    But if I create an appointment somewhere in the middle of all appointments - DataContext in the Loaded-event is the last appointment again and it will animate again. 

    Can You explain why does this happen?

    private void templateGrid_Loaded(object sender, RoutedEventArgs e)
         if ((((sender as Grid).DataContext as Telerik.Windows.Controls.AppointmentItemProxy).Appointment as AppointmentWrapper).NewFlag)
           ((sender as Grid).Resources["colorizeStoryboard"] as Storyboard).Begin();
    <DataTemplate x:Key="AppointmentItemTemplate" >
                <Grid VerticalAlignment="Top" Name="templateGrid"Loaded="templateGrid_Loaded">
                        <Storyboard x:Key="colorizeStoryboard">
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="templateGrid" Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)" >
                                <EasingColorKeyFrame KeyTime="00:00:02" Value="Green" />
                                <EasingColorKeyFrame KeyTime="00:00:04" Value="Blue" />
                                <EasingColorKeyFrame KeyTime="00:00:06" Value="Transparent" />
                <TextBlock Margin="8,2" TextWrapping="Wrap" Text="{Binding Appointment.Subject}" />

Back to Top