private void TitleResize(object sender, SizeChangedEventArgs e) { if (TitleText.ActualHeight < 70) { vb.Stretch = Stretch.None; ButtonsPanel.VerticalAlignment = System.Windows.VerticalAlignment.Center; var anim = new ThicknessAnimation { To = new Thickness(55, 0, 0, 0), Duration = new Duration(new TimeSpan(0, 0, 0, 0, 100)) }; ButtonsPanel.Margin = new Thickness(55, 0, 0, 0); } if (TitleText.ActualHeight > 70) { ButtonsPanel.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; ButtonsPanel.Margin = new Thickness(0, 0, 0, 0); } if ((TitleText.ActualHeight < 84)) { var anim = new DoubleAnimation { To = 0, Duration = new TimeSpan(0, 0, 0, 0, 150), }; vb.Stretch = Stretch.None; TitleLabel.BeginAnimation(UIElement.OpacityProperty, anim); } else { vb.Stretch = Stretch.Uniform; var anim = new DoubleAnimation { To = 1, Duration = new TimeSpan(0, 0, 0, 0, 150), }; TitleLabel.BeginAnimation(UIElement.OpacityProperty, anim); } }