C# 与动画冲突。再次打开longlistselector后,带有动画的元素会淡出
但每当我将两个元素(或更多元素(我在测试时使用两个元素))旋转到不同的侧面时,我就会面临下一个问题:当longlistselector再次打开时,对象会从屏幕上消失。不过,我为所有对象正确设置了可见性。对象可能会同时消失,即使我不触摸对象,添加新对象时也会出现相同的图片:如果我已翻转上一个对象,下一个对象将显示为空,就像两个栅格的可见性属性都设置为“折叠”。但事实并非如此 很抱歉,我还不能发布图片C# 与动画冲突。再次打开longlistselector后,带有动画的元素会淡出,c#,wpf,silverlight,animation,windows-phone-8,C#,Wpf,Silverlight,Animation,Windows Phone 8,但每当我将两个元素(或更多元素(我在测试时使用两个元素))旋转到不同的侧面时,我就会面临下一个问题:当longlistselector再次打开时,对象会从屏幕上消失。不过,我为所有对象正确设置了可见性。对象可能会同时消失,即使我不触摸对象,添加新对象时也会出现相同的图片:如果我已翻转上一个对象,下一个对象将显示为空,就像两个栅格的可见性属性都设置为“折叠”。但事实并非如此 很抱歉,我还不能发布图片 <phone:LongListSelector Margin="0,0,-22,0" Ite
<phone:LongListSelector Margin="0,0,-22,0" ItemsSource="{Binding CardItems}" Name="cardsList" SelectionChanged="cardsList_SelectionChanged">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="12,2,0,4" Height="220">
<Grid>
<Grid x:Name="cardBack" Height="200" Width="300" Visibility="{Binding visualBackSide, Mode=TwoWay}">
<Image Source="/Assets/BackCard.png"/>
<TextBox Background="Transparent" BorderBrush="Transparent" TextWrapping="Wrap" Height="140" Width="250" Text="{Binding CardFrontSide, Mode=TwoWay}" TextAlignment="Center" />
<Grid.Projection>
<PlaneProjection/>
</Grid.Projection>
</Grid>
<Grid x:Name="cardFront" Height="200" Width="300" Visibility="{Binding visualFrontSide, Mode=TwoWay}">
<Image Source="/Assets/FrontCard.png"/>
<TextBox Background="Transparent" BorderBrush="Transparent" TextWrapping="Wrap" Height="170" Width="280" Text="{Binding CardBackSide, Mode=TwoWay}" TextAlignment="Center" />
<Grid.Projection>
<PlaneProjection/>
</Grid.Projection>
</Grid>
<Grid.Resources>
<Storyboard x:Name="flipTo" >
<PointAnimation Duration="0:0:2" To="0.5,0.5" Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="cardBack" d:IsOptimized="True"/>
<DoubleAnimation Duration="0:0:2" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="cardBack" d:IsOptimized="True"/>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="cardFront">
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="cardFront">
<DiscreteObjectKeyFrame KeyTime="0:0:2">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="cardBack">
<DiscreteObjectKeyFrame KeyTime="0:0:2">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Name="flipFrom">
<PointAnimation Duration="0:0:2" To="0.5,0.5" Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="cardFront" d:IsOptimized="True"/>
<DoubleAnimation Duration="0:0:2" To="90" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="cardFront" d:IsOptimized="True"/>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="cardBack">
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="cardBack">
<DiscreteObjectKeyFrame KeyTime="0:0:2">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="cardFront">
<DiscreteObjectKeyFrame KeyTime="0:0:2">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
</Grid>
<StackPanel>
<Button toolkit:TiltEffect.IsTiltEnabled="True" BorderThickness="0" Click="DeleteCard_Click" Style="{StaticResource ButtonPressedTransparent}">
<Image Source="/Assets/AppBarButtons/delete.png"/>
</Button>
<Button toolkit:TiltEffect.SuppressTilt="True" BorderThickness="0" Click="FlipCard_Click" Style="{StaticResource ButtonPressedTransparent}">
<Image Source="/Assets/AppBarButtons/refresh.png"/>
</Button>
</StackPanel>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
<phone:LongListSelector.ListFooterTemplate>
<DataTemplate>
<Button Content="Add new card" Width="200" Click="AddNewCard_Click"/>
</DataTemplate>
</phone:LongListSelector.ListFooterTemplate>
</phone:LongListSelector>
private void FlipCard_Click(object sender, RoutedEventArgs e)
{
var temp = sender as Button;
StackPanel stp = (StackPanel)temp.Parent;
StackPanel stp1 = (StackPanel)stp.Parent;
Grid all = (Grid)stp1.Children[0];
Grid cardBack = (Grid)all.Children[0];
Grid cardFront = (Grid)all.Children[1];
if (cardBack.Visibility == Visibility.Visible)
{
Storyboard sb = all.Resources["flipTo"] as Storyboard;
sb.Begin();
cardBack.Visibility = Visibility.Collapsed;
cardFront.Visibility = Visibility.Visible;
}
else
{
Storyboard sb = all.Resources["flipFrom"] as Storyboard;
sb.Begin();
cardBack.Visibility = Visibility.Visible;
cardFront.Visibility = Visibility.Collapsed;
}
}