Post: [C#] Fade In/Out Controls
05-11-2015, 04:58 PM #1
jagex
Gym leader
(adsbygoogle = window.adsbygoogle || []).push({}); *System.Windows.Media.Animations
*Works for controls that have an opacity property
*Opacity values range from 0.00 - 1.00

0 = not visible
1 = visible

Some examples:
    
static double opacityValue = 0;

public static void fadeIn(Image image, double duration)
{
image.Opacity = opacityValue;
var fadeTime = new DoubleAnimation(opacityValue, 1, TimeSpan.FromSeconds(duration));
image.BeginAnimation(System.Windows.UIElement.OpacityProperty, fadeTime);
}
public static void fadeIn(Label label, double duration)
{
label.Opacity = opacityValue;
var fadeTime = new DoubleAnimation(opacityValue, 1, TimeSpan.FromSeconds(duration));
label.BeginAnimation(System.Windows.UIElement.OpacityProperty, fadeTime);
}
public static void fadeOut(Image image, double duration)
{
image.Opacity = opacityValue;
var fadeTime = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(duration));
image.BeginAnimation(System.Windows.UIElement.OpacityProperty, fadeTime);
}
public static void fadeOut(Label label, double duration)
{
label.Opacity = opacityValue;
var fadeTime = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(duration));
label.BeginAnimation(System.Windows.UIElement.OpacityProperty, fadeTime);
}
Last edited by jagex ; 05-11-2015 at 05:03 PM.
05-11-2015, 08:40 PM #2
Mr Smithy x
Former Staff
Interesting, nice share c:
05-11-2015, 09:02 PM #3
jagex
Gym leader
Thanks Kaneki hehe :p

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo