Partage
  • Partager sur Facebook
  • Partager sur Twitter

Animation Xaml ou C#

Rectangle Stroke animé

    26 octobre 2019 à 23:00:36

    Bonjour, j'essaie (tant bien que mal) de faire une animation pour une zone de drag&drop sur mon application wpf. J'aimerais réaliser la même animation qu'avec le code ci-dessous, mais sans avoir à utiliser de width ou height définis au pixel, pour la compatibilité des résolutions d'écrans.

    private void Grid_MouseEnter(object sender, MouseEventArgs e)
    {
    	DoubleAnimation resizeScaleY = new DoubleAnimation(400, 350, new Duration(TimeSpan.FromSeconds(0.1)));
    	DoubleAnimation resizeScaleX = new DoubleAnimation(850, 800, new Duration(TimeSpan.FromSeconds(0.1)));
    	DropZone.BeginAnimation(WidthProperty, resizeScaleX);
    	DropZone.BeginAnimation(HeightProperty, resizeScaleY);
    }
    private void Grid_MouseLeave(object sender, MouseEventArgs e)
    {
    	DoubleAnimation resizeScaleX = new DoubleAnimation(800, 850, new Duration(TimeSpan.FromSeconds(0.1)));
    	DoubleAnimation resizeScaleY = new DoubleAnimation(350, 400, new Duration(TimeSpan.FromSeconds(0.1)));
    	DropZone.BeginAnimation(WidthProperty, resizeScaleX);
    	DropZone.BeginAnimation(HeightProperty, resizeScaleY);
    }
    
    <Grid Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="4" Grid.RowSpan="4" MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave">
        <Border Background="#FF616060">
            <Grid x:Name="DropZone" Margin="25">
                <Rectangle Fill="Transparent" Stroke="Red" StrokeDashArray="3" StrokeThickness="5" RenderTransformOrigin="0.5,0.5"/>
            </Grid>
        </Border>
    </Grid>


    Une âme charitable pourrait-elle m'aider ?

    • Partager sur Facebook
    • Partager sur Twitter

    Animation Xaml ou C#

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown