Color Animation not work ::PLZ Help Me::

Oct 15, 2010 at 3:03 AM
Edited Oct 15, 2010 at 10:21 PM

i have a grid in list box in as A Template Structure because i want to make that list box appear like A Container for Icons so i have that code in xaml 

 

<ListBox.ItemTemplate>

 

<DataTemplate>

 

<Grid x:Name="grid" HorizontalAlignment="Center" Width="200" Height="200" MouseMove="grid_MouseMove">

 

<Grid.Background>

 

<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 

<GradientStop Color="Black" Offset="0"/>

 

<GradientStop Color="#FFC61111" Offset="1"/>

 

</LinearGradientBrush>

 

</Grid.Background>

 

<Grid.RowDefinitions> 

<RowDefinition Height="60"/>

 

<RowDefinition Height="40"/>

 

<RowDefinition Height="40"/>

 

</Grid.RowDefinitions>

 

<Image Source="{Binding Path=ImageUrl}" Width="60" Height="60" Margin="1,1,1,1" Stretch="Uniform" Grid.Row="0"/>

 

<TextBlock Text="{Binding Path=Name}" TextAlignment="Center" Width="190" TextWrapping="Wrap" HorizontalAlignment="Center" FontWeight="Bold" Grid.Row="1"/>

 

<HyperlinkButton Width="190" Height="150" NavigateUri="{Binding Path=SiteUrl}" Content="{Binding Path=SiteUrl}" Foreground="Black" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Stretch" Grid.Row="2" ToolTipService.ToolTip="{Binding Path=SiteUrl}"/>

 

</Grid>

 

</DataTemplate>

 

</ListBox.ItemTemplate>

 

  

  

After that i have a storyboard created by Expression blend i added as a resource

<UserControl.Resources>

 

<Storyboard x:Name="Storyboard1">

 

<ColorAnimation Duration="0:0:2" To="#FF1114C6" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="grid" d:IsOptimized="True"/>

 

</Storyboard>

 

</UserControl.Resources>

 

 And I begin that story board in mouse move for Grid but it Give me An Exception

System.InvalidOperationException: Cannot resolve TargetProperty (Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color) on specified object.
   at MS.Internal.XcpImports.VisualStateManager_GoToState(Control reference, String StateName, Boolean useTransitions, Boolean& refreshInheritanceContext)
   at System.Windows.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions)
   at System.Windows.Controls.ListBoxItem.ChangeVisualState(Boolean useTransitions)
   at System.Windows.Controls.ListBoxItem.OnMouseEnter(MouseEventArgs e)
   at System.Windows.Controls.Control.OnMouseEnter(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)