stride3d/stride · error · ArgumentNullException

ArgumentNullException: element

Error message

ArgumentNullException: element

What it means

GetStatus is a WPF attached-property getter that reads the StatusProperty (a StatusViewModel) from a FrameworkElement. The library throws ArgumentNullException when the element parameter is null because there is no valid dependency object to read the attached property from.

Solutions

  1. Pass a valid FrameworkElement instance to GetStatus
  2. Null-check the element (or the result of FindName/templated parent lookup) before calling GetStatus
  3. Verify the caller is invoked from a WPF UI context where the element is fully loaded

Example fix

// before
var status = ToolTipHelper.GetStatus(someControl);
// after
var status = someControl != null ? ToolTipHelper.GetStatus(someControl) : null;
Defensive patterns

Strategy: type-guard

Validate before calling

if (element == null) return null; // or skip the GetStatus call

Type guard

bool HasStatus(FrameworkElement e) => e != null && ToolTipHelper.GetStatus(e) != null;

Try / catch

try { var status = ToolTipHelper.GetStatus(element); } catch (ArgumentNullException) { /* element was null; handle absence of status */ }

Prevention

When it happens

Trigger: Calling ToolTipHelper.GetStatus(null), e.g. when a data-bound or templated lookup passes a control that failed to resolve (sender/cached element null, FindName miss, or a view model mistakenly passed instead of the control).

Common situations: Event handlers like ToolTipOpening where the source is unexpectedly null; control template lookups returning null; passing a DataContext instead of the FrameworkElement.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/14315426dff40d0b. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Core.Assets.Editor/Components/Status/Views/ToolTipHelper.cs:24

using System.Windows.Controls;
using System.Windows.Documents;
using Stride.Core.Presentation.Extensions;

namespace Stride.Core.Assets.Editor.Components.Status.Views
{
    public static class ToolTipHelper
    {
        public static readonly DependencyProperty StatusProperty =
            DependencyProperty.RegisterAttached("Status", typeof(StatusViewModel), typeof(ToolTipHelper), new PropertyMetadata(null, OnStatusChanged));

        private static readonly DependencyPropertyKey StatusTokenPropertyKey =
            DependencyProperty.RegisterAttachedReadOnly("StatusToken", typeof(int), typeof(ToolTipHelper), new PropertyMetadata(-1));

        private static readonly DependencyProperty StatusTokenProperty = StatusTokenPropertyKey.DependencyProperty;
        
        public static StatusViewModel GetStatus(FrameworkElement element)
        {
            if (element == null) throw new ArgumentNullException(nameof(element));

            return (StatusViewModel)element.GetValue(StatusProperty);
        }

        public static void SetStatus(FrameworkElement element, StatusViewModel value)
        {
            if (element == null) throw new ArgumentNullException(nameof(element));

            element.SetValue(StatusProperty, value);
        }

        private static int GetStatusToken(FrameworkElement element)
        {
            if (element == null) throw new ArgumentNullException(nameof(element));

            return (int)element.GetValue(StatusTokenProperty);
        }

View on GitHub (pinned to 96fad776d2)