Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaterialDesignSwitchToggleButton: 'System.Windows.Media.Animation.DoubleAnimation' cannot use default origin value of 'NaN' on Window Exit #3740

Open
TWhidden opened this issue Dec 12, 2024 · 3 comments
Labels
bug evaluation required Items is pending review or evaluation by the team

Comments

@TWhidden
Copy link

Bug explanation

Moving to Material Design 3. Having a problem with MaterialDesignSwitchToggleButton. The other ToggleButtons styles don't appear to have this exception.

When closing the parent window after this style has been loaded, I get an exception. I am guessing the exit animation is causing this. Not sure if it's because there is no from value?

I am still researching this and have not created a side project to test this yet. That will be next, but under pressure to finish this project, so will select a different style for the meantime.

Exception is crazy long, so will post the final part of it.

System.InvalidOperationException: 'System.Windows.Media.Animation.DoubleAnimation' cannot use default origin value of 'NaN'.
   at System.Windows.Media.Animation.DoubleAnimation.GetCurrentValueCore(Double defaultOriginValue, Double defaultDestinationValue, AnimationClock animationClock)
   at System.Windows.Media.Animation.DoubleAnimationBase.GetCurrentValue(Object defaultOriginValue, Object defaultDestinationValue, AnimationClock animationClock)
   at System.Windows.Media.Animation.AnimationStorage.GetCurrentPropertyValue(AnimationStorage storage, DependencyObject d, DependencyProperty dp, PropertyMetadata metadata, Object baseValue)
   at System.Windows.Media.Animation.AnimationStorage.EvaluateAnimatedValue(PropertyMetadata metadata, EffectiveValueEntry& entry)
   at System.Windows.UIElement.EvaluateAnimatedValueCore(DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry& entry)

More to come - but opening this up just in case there is something obvious I may be missing.

Xaml usage:

<ToggleButton Style="{DynamicResource MaterialDesignSwitchToggleButton}"
              ToolTip="Something"
              IsChecked="{Binding SomeBoolBinding, Mode=TwoWay}"
              Margin="2" />

Version

5.1.0

@TWhidden TWhidden added bug evaluation required Items is pending review or evaluation by the team labels Dec 12, 2024
@corvinsz
Copy link
Contributor

@TWhidden If I understand correctly, the reproduction steps should be:

  1. Open a new Window containing XAML you provided (ToggleButton and the approriate style)
  2. Closing the Window should raise an unhandled exception

I am unable to reproduce this problem using the Material Design 3 defaults:
395200963-d962512c-f3f0-4149-bef0-15f0ced51ce8

@TWhidden
Copy link
Author

It appears there's an environmental issue in my setup. For the demo, I had to revert to a standard checkbox to bypass the problem, but I plan to investigate further soon.

Could you please zip up that quick test, drop a link? I’d like to apply the application-specific settings to see if I can reproduce the issue. I suspect it might be related to how I’m applying styles. Since I'm integrating it as a plugin within another application, I couldn't apply the styles to the global App resources without causing conflicts in the host application (poisoned their visuals tree with my styles and colors). Currently, the style is loaded as a merged dictionary and applied throughout the child visual tree, including the popup with the same resource applied at the window level.

Interestingly, other Material Design visuals function correctly, and the issue seems to be isolated to the ToggleButton at this time.

I'll have more time next week to poke at this, as I really like the MD3 ToggleButton styles.

Thanks for looking into this!

@corvinsz
Copy link
Contributor

Here you go: https://github.com/corvinsz/MDIX3740
I'm quite busy currently, so you are welcome to fiddle around yourself 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team
Projects
None yet
Development

No branches or pull requests

2 participants