private void Button_Click(object sender, RoutedEventArgs e) { if (Name.Text != "") { DialogResult = true; } else { var da = new DoubleAnimation(); da.From = 1; da.To = 0; da.Duration = new TimeSpan(0, 0, 0, 0, 200); da.AutoReverse = true; Name.BeginAnimation(TextBox.OpacityProperty, da); } }