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

ItemTemplate animation bug

0 Answers 39 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Oleg
Top achievements
Rank 1
Oleg asked on 02 Nov 2011, 10:44 AM
Hello Telerik team!
As I've already posted here: http://www.telerik.com/community/forums/silverlight/scheduleview/appointment-creation-animation.aspx#1837399
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">
                <Grid.Resources>
                    <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" />
                        </ColorAnimationUsingKeyFrames>
                    </Storyboard>                        
                </Grid.Resources>
            <TextBlock Margin="8,2" TextWrapping="Wrap" Text="{Binding Appointment.Subject}" />
        </Grid>
    </DataTemplate>

No answers yet. Maybe you can help?

Tags
ScheduleView
Asked by
Oleg
Top achievements
Rank 1
Share this question
or