C
C#•3mo ago
zeroo

cant get user control showing after its opened and closed

lowkey needing help i cant get this working once its opened and closed it doesnt open anymore i tried debugging it and it does change the proprities but nothing pops up?
// the settings overlay closer
private void ReturnButton_Click(object sender, RoutedEventArgs e)
{
Debug.WriteLine("recieved initial visibility: " + this.Visibility);
Debug.WriteLine("recieved initial width: " + this.Width);
double targetWidth = 0;
TimeSpan duration = TimeSpan.FromSeconds(0.5);

DoubleAnimation widthAnimation = new DoubleAnimation
{
From = this.ActualWidth,
To = targetWidth,
Duration = new Duration(duration),
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
};

widthAnimation.Completed += (s, e) =>
{
this.Width = double.NaN;
this.Visibility = Visibility.Hidden;

Debug.WriteLine("closed visibility: " + this.Visibility);
Debug.WriteLine("closed width: " + this.Width);
};

this.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation);
}
}
// the settings overlay closer
private void ReturnButton_Click(object sender, RoutedEventArgs e)
{
Debug.WriteLine("recieved initial visibility: " + this.Visibility);
Debug.WriteLine("recieved initial width: " + this.Width);
double targetWidth = 0;
TimeSpan duration = TimeSpan.FromSeconds(0.5);

DoubleAnimation widthAnimation = new DoubleAnimation
{
From = this.ActualWidth,
To = targetWidth,
Duration = new Duration(duration),
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
};

widthAnimation.Completed += (s, e) =>
{
this.Width = double.NaN;
this.Visibility = Visibility.Hidden;

Debug.WriteLine("closed visibility: " + this.Visibility);
Debug.WriteLine("closed width: " + this.Width);
};

this.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation);
}
}
private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
if (SettingsOverlay.Visibility == Visibility.Hidden)
{
Debug.WriteLine("Initial visibility: " + SettingsOverlay.Visibility);
SettingsOverlay.Visibility = Visibility.Visible;
SettingsUserControl.Visibility = Visibility.Visible;
SettingsOverlay.Width = 0;

double targetWidth = 450;
TimeSpan duration = TimeSpan.FromSeconds(0.5);

DoubleAnimation widthAnimation = new DoubleAnimation
{
From = 0,
To = targetWidth,
Duration = new Duration(duration),
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
};

widthAnimation.Completed += (s, e) =>
{
SettingsOverlay.Width = double.NaN;
SettingsOverlay.Visibility = Visibility.Visible;
SettingsUserControl.Visibility = Visibility.Visible;
Debug.WriteLine("opening visibility: " + SettingsOverlay.Visibility);
Debug.WriteLine("opening width: " + SettingsOverlay.Width);
};

SettingsOverlay.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation);
}
}
private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
if (SettingsOverlay.Visibility == Visibility.Hidden)
{
Debug.WriteLine("Initial visibility: " + SettingsOverlay.Visibility);
SettingsOverlay.Visibility = Visibility.Visible;
SettingsUserControl.Visibility = Visibility.Visible;
SettingsOverlay.Width = 0;

double targetWidth = 450;
TimeSpan duration = TimeSpan.FromSeconds(0.5);

DoubleAnimation widthAnimation = new DoubleAnimation
{
From = 0,
To = targetWidth,
Duration = new Duration(duration),
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
};

widthAnimation.Completed += (s, e) =>
{
SettingsOverlay.Width = double.NaN;
SettingsOverlay.Visibility = Visibility.Visible;
SettingsUserControl.Visibility = Visibility.Visible;
Debug.WriteLine("opening visibility: " + SettingsOverlay.Visibility);
Debug.WriteLine("opening width: " + SettingsOverlay.Width);
};

SettingsOverlay.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation);
}
}
17 Replies
iXyles
iXyles•3mo ago
Does the animation automatically set the "visibility" back to visible? Or else that seems like the reason? 🙂
zeroo
zeroo•3mo ago
i made it set the visibility when the animation is completed
iXyles
iXyles•3mo ago
Ah right now I saw it, sorry - out of luck from a quick look at it 😄
zeroo
zeroo•3mo ago
no problem dont worry im still tryna figure it out could it be a overlapping issue @iXyles i tried debugging it Initial visibility: Hidden opening visibility: Visible opening width: 450 recieved initial visibility: Visible recieved initial width: 450 closed visibility: Hidden closed width: 0 Initial visibility: Hidden opening visibility: Visible opening width: 450 it opens it but its not showing i stilll need help if anyone could help
arion
arion•3mo ago
What's the difference between ActualWidth and Width?
zeroo
zeroo•3mo ago
well ActualWidth gets the current width also 1 is read only and one is writable what actual width does is ig get the actual width after creating the layout if im not wrong
arion
arion•3mo ago
In your closing animation, your target is 0 Width. But when you complete it you set it to NAN. Is there a reason behind this?
zeroo
zeroo•3mo ago
to make it fill the ui double.nan is auto
arion
arion•3mo ago
When closing it fills the UI?
zeroo
zeroo•3mo ago
ig i tried with 0 but nothing rlly changes
arion
arion•3mo ago
What do you mean?
zeroo
zeroo•3mo ago
i mean the problem
arion
arion•3mo ago
So you've tried it without the SettingsOverlay.Width = double.NaN;? If so isn't its assignment redundant?
zeroo
zeroo•3mo ago
i mean i tried also using 0 as width but its still the same problem
arion
arion•3mo ago
Hm, okay then. What's the classes for the first and second method? Is the first "SettingsOverlay" right?
Want results from more Discord servers?
Add your server