I read quite a few questions about choppy animations here but sadly none have solved my issue.
I have a window and under some circumstances (checkbox check) the window height should increase or decrease.
I wrote a small method for the animation and when the checkbox is checked it executes the method.
public static void NewWindowHeight(MainWindow MainWindow1, int Height)
{
double oldheight = MainWindow1.Height;
DoubleAnimation animation = new DoubleAnimation(oldheight, Height, TimeSpan.FromSeconds(0.2));
MainWindow1.BeginAnimation(MainWindow.HeightProperty, animation);
}
I have two checkboxes and at a defined combination the window height should be set to a specific value. This is the code behind the checkbox_clicked method. (I only show this one because it is basically the same code with the other checkbox)
private void CheckBoxSetup_Click(object sender, RoutedEventArgs e)
{
if (CheckBoxSetup.IsChecked == false && CheckBoxUpdate.IsChecked == false)
{
MethodsClass.NewWindowHeight(MainWindow1, 180);
}
if (CheckBoxSetup.IsChecked == true || CheckBoxUpdate.IsChecked == true)
{
MethodsClass.NewWindowHeight(MainWindow1, 220);
}
if (CheckBoxSetup.IsChecked == true && CheckBoxUpdate.IsChecked == true)
{
MethodsClass.NewWindowHeight(MainWindow1, 260);
}
}
All works well, but the animation is kinda choppy. Not terrible but definetily not smooth. What could be the reason for this? How could i solve this?
Some pictures for better understanding:
Aucun commentaire:
Enregistrer un commentaire