MahApps/MahApps.Metro · error · MahAppsException

Uups, it seems like there is something wrong with the given

Error message

Uups, it seems like there is something wrong with the given BadgeChangedStoryboard.

What it means

Badged.OnBadgeChanged fires a configured Storyboard (BadgeChangedStoryboard) on its badge container when the badge value changes. If BeginStoryboard throws, the exception is wrapped in a MahAppsException indicating the storyboard is malformed or cannot run. The inner exception carries the real WPF animation error.

Source

Thrown at src/MahApps.Metro/Controls/Badged.cs:53

            this.BadgeChanged -= this.OnBadgeChanged;

            base.OnApplyTemplate();

            this.BadgeChanged += this.OnBadgeChanged;
        }

        private void OnBadgeChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            var sb = this.BadgeChangedStoryboard;
            if (this._badgeContainer != null && sb != null)
            {
                try
                {
                    this._badgeContainer.BeginStoryboard(sb);
                }
                catch (Exception exception)
                {
                    throw new MahAppsException("Uups, it seems like there is something wrong with the given BadgeChangedStoryboard.", exception);
                }
            }
        }
    }
}

View on GitHub (pinned to 72099e310b)

Solutions

  1. Inspect InnerException of the MahAppsException for the precise WPF animation error (target name, property path).
  2. Fix the storyboard XAML: correct TargetName/TargetProperty to match the badge container template, remove duplicate animations.
  3. Remove BadgeChangedStoryboard if animation is not required, so the badge updates without a storyboard.
  4. Test the storyboard in isolation (Blend/XAML designer) to validate timelines before binding it to the control.

Example fix

<!-- before: target name no longer exists in template -->
<Storyboard x:Key="BadgeChangedStoryboard">
  <DoubleAnimation Storyboard.TargetName="MissingPart" .../>
</Storyboard>
<!-- after -->
<Storyboard x:Key="BadgeChangedStoryboard">
  <DoubleAnimation Storyboard.TargetName="BadgeContainer" Storyboard.TargetProperty="(UIElement.Opacity)" To="1" Duration="0:0:0.2"/>
</Storyboard>
Defensive patterns

Strategy: try-catch

Validate before calling

// If a storyboard is optional, validate it can run before assigning
if (myStoryboard != null) {
    // optionally resolve target names against the template to fail early
    badged.BadgeChangedStoryboard = myStoryboard;
}

Try / catch

try {
    _badgeContainer.BeginStoryboard(sb);
} catch (Exception ex) {
    // log and degrade gracefully (update badge without animation)
    Logger.Error(ex, "BadgeChangedStoryboard failed; disabling animation");
    Badged.SetIsBadgeChangedStoryboardEnabled(..., false); // app-level fallback
}

Prevention

When it happens

Trigger: A BadgeChangedStoryboard is set on a Badged control, the badge value changes at runtime, and Storyboard.Begin fails — e.g. the storyboard references a missing timeline, an unknown property path, or targets a name that no longer exists.

Common situations: Custom BadgeChangedStoryboard XAML has a bad TargetName or PropertyPath. Storyboard was authored for a template that was later restyled and the target name vanished. Conflicting double animations on the same property. Storyboard defined in a resource that fails to resolve.

Related errors


AI-assisted analysis of MahApps/MahApps.Metro@72099e310b (2026-08-13). Data as JSON: /api/errors/21dba6b98c05a629. Report an issue: GitHub.