private void WidthDoubleAnimationStart <T>(object obj, double oldValue, double newValue, double duration) { DoubleAnimation animation = new DoubleAnimation(oldValue, newValue, TimeSpan.FromSeconds(duration)); if (typeof(T) == typeof(TextBlock)) { TextBlock textBlock = (TextBlock)obj; textBlock.BeginAnimation(TextBlock.WidthProperty, animation); } else if (typeof(T) == typeof(Grid)) { Grid grid = (Grid)obj; grid.BeginAnimation(Grid.WidthProperty, animation); } else if (typeof(T) == typeof(Separator)) { Separator separator = (Separator)obj; separator.BeginAnimation(WidthProperty, animation); } else if (typeof(T) == typeof(Window)) { Window window = (Window)obj; window.BeginAnimation(WidthProperty, animation); } }
private void HeightDoubleAnimationStart <T>(object obj, double oldValue, double newValue, double duration) { DoubleAnimation animation = new DoubleAnimation(oldValue, newValue, TimeSpan.FromSeconds(duration)); if (typeof(T) == typeof(TextBlock)) { TextBlock textBlock = (TextBlock)obj; textBlock.BeginAnimation(TextBlock.HeightProperty, animation); } else if (typeof(T) == typeof(Grid)) { Grid grid = (Grid)obj; grid.BeginAnimation(Grid.HeightProperty, animation); } else if (typeof(T) == typeof(Separator)) { Separator separator = (Separator)obj; separator.BeginAnimation(HeightProperty, animation); } else if (typeof(T) == typeof(Button)) { Button button = (Button)obj; button.BeginAnimation(HeightProperty, animation); } }