2016-07-21 1 views
2

Comment puis-je atteindre THIS type d'animation? Je suis très nouveau à WPF. J'ai essayé avec DoubleAnimation dans WPF mais pas atteint la cible.Animation de blocs de texte WPF

L'animation doit être se produire lorsque je mets à jour le score comme dans la vidéo, il se passe quand score est mise à jour de 17 à 23.

Merci!

+0

Je ne peux pas voir le lien que vous avez posté: Ce site est sous forte charge :-) Je vais essayer plus tard! –

+1

Je vois l'animation. Il est difficile d'écrire XAML pour vous ici. Fondamentalement, vous avez besoin de deux DoubleAnimation: une pour contrôler l'opacité du TextBlock, et une autre pour contrôler la traduction. –

+0

merci! Igor Damiani. Mais honnêtement, je ne sais pas comment écrire :) encore je vais essayer. Si vous pouvez faire plus d'aide alors plz m'aider. Pour info, j'utilise VS 2015 – waghekapil

Répondre

2

Essayez ceci. Essayez de jouer avec la marge, la durée, et ainsi de suite!

<Window x:Class="WpfApplication1.AnimWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:WpfApplication1" 
    mc:Ignorable="d" 
    Title="AnimWindow" Height="300" Width="300"> 

<Window.Triggers> 
    <EventTrigger RoutedEvent="Window.Loaded"> 
     <BeginStoryboard> 
      <Storyboard> 
       <DoubleAnimation Storyboard.TargetName="PointsNew" To="1.0" Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" /> 
       <DoubleAnimation Storyboard.TargetName="PointsOld" To="0.0" Storyboard.TargetProperty="Opacity" Duration="0:0:0.5" /> 
       <ThicknessAnimation Storyboard.TargetName="PointsNew" From="0 -32 0 0" To="0 0 0 0" Storyboard.TargetProperty="Margin" Duration="0:0:0.5" /> 
       <ThicknessAnimation Storyboard.TargetName="PointsOld" To="0 32 0 0" Storyboard.TargetProperty="Margin" Duration="0:0:0.5" /> 
      </Storyboard> 
     </BeginStoryboard> 
    </EventTrigger> 
</Window.Triggers> 

<Grid> 
    <Border HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0.0" x:Name="PointsNew"> 
     <TextBlock Text="23" FontSize="96" FontWeight="Bold" /> 
    </Border> 
    <Border HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="1.0" x:Name="PointsOld"> 
     <TextBlock Text="17" FontSize="96" FontWeight="Bold" /> 
    </Border> 
</Grid></Window> 

Essayez de jouer avec la marge, la durée, et ainsi de suite! :-)

+0

Merci. Laisse-moi essayer. – waghekapil

+0

Ohh mec, vous êtes génial! C'est exactement ce que je cherchais. Merci beaucoup. Merci, merci, merci (y) – waghekapil