private void TabItem_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var selected = sender as TabItem; if (selected != null) { selected.IsSelected = true; } if (Math.Abs(_border.ActualHeight - 100) < 0) { return; } var animation = new DoubleAnimation(_border.ActualHeight, 100, new Duration(new TimeSpan(0, 0, 0, 1))) { EasingFunction = new PowerEase { Power = 8 } }; _border.BeginAnimation(HeightProperty, animation); var opacityAnimation = new DoubleAnimation(_border.Opacity, 1, new Duration(new TimeSpan(0, 0, 0, 1))) { EasingFunction = new PowerEase { Power = 8 } }; _border.BeginAnimation(OpacityProperty, opacityAnimation); var visibilityAnimation = new ObjectAnimationUsingKeyFrames(); visibilityAnimation.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5)))); _hideButton.BeginAnimation(VisibilityProperty, visibilityAnimation); //Marging = 5,5,0,-1 var marginAnimation = new ThicknessAnimation(_tabPanel.Margin, new Thickness(5, 5, 0, -1), new Duration(new TimeSpan(0, 0, 0, 0, 1))) { EasingFunction = new PowerEase { Power = 8 } }; _tabPanel.BeginAnimation(MarginProperty, marginAnimation); }