首先定义模板:
"ItemTemplate">"470" Margin="0,30,0,0" Tap="Grid_Tap" x:Name="grid">"370"/>"100"/>"60"/>"Auto"/>"25" />"{Binding comments_count}" Width="41" Margin="60,18,0,-4" HorizontalAlignment="Left" Foreground="#FFABD623"/>"{Binding has_uped, Mode=TwoWay}" Margin="0,8,85,-37" Content="has_uped" Visibility="Collapsed" HorizontalAlignment="Right" Width="63"/>"{Binding img_url}" Margin="0,20,0,0" Grid.Row="1" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Left" Height="90" Width="90"/>"{Binding is_break, Mode=TwoWay}" Margin="0,8,-15,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="66" Content="is_break" Visibility="Collapsed"/>"{Binding title}" TextWrapping="Wrap" Margin="0,1,0,0" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White"/>"{Binding url}" Grid.Row="2" Margin="60,-4,38,4" Grid.ColumnSpan="2" d:LayoutOverrides="GridBox" Foreground="#FF956020"/>"Left" Margin="0,19,0,-1" TextWrapping="Wrap" Text="评论数:" Width="56" FontSize="16" Foreground="#FFABD623"/>"Left" Grid.Row="2" TextWrapping="Wrap" Text="网址:" FontSize="16" Foreground="#FF956020" />
在 codebehind 页面中捕获sender,并播放动画
private void TxtbUps_Tap(object sender, System.Windows.Input.GestureEventArgs e){Button btn = sender as Button;Storyboard sb = btn.Resources["AddOneStoBoard"] as Storyboard;if (sb != null){sb.Begin();}//e.Handled = true;}
点击按钮后,动画播放。