{"record":{"id":"14315426dff40d0b","repo":"stride3d/stride","slug":"argumentnullexception-element","errorCode":null,"errorMessage":"ArgumentNullException: element","messagePattern":"ArgumentNullException: element","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/Components/Status/Views/ToolTipHelper.cs","lineNumber":24,"sourceCode":"using System.Windows.Controls;\nusing System.Windows.Documents;\nusing Stride.Core.Presentation.Extensions;\n\nnamespace Stride.Core.Assets.Editor.Components.Status.Views\n{\n    public static class ToolTipHelper\n    {\n        public static readonly DependencyProperty StatusProperty =\n            DependencyProperty.RegisterAttached(\"Status\", typeof(StatusViewModel), typeof(ToolTipHelper), new PropertyMetadata(null, OnStatusChanged));\n\n        private static readonly DependencyPropertyKey StatusTokenPropertyKey =\n            DependencyProperty.RegisterAttachedReadOnly(\"StatusToken\", typeof(int), typeof(ToolTipHelper), new PropertyMetadata(-1));\n\n        private static readonly DependencyProperty StatusTokenProperty = StatusTokenPropertyKey.DependencyProperty;\n        \n        public static StatusViewModel GetStatus(FrameworkElement element)\n        {\n            if (element == null) throw new ArgumentNullException(nameof(element));\n\n            return (StatusViewModel)element.GetValue(StatusProperty);\n        }\n\n        public static void SetStatus(FrameworkElement element, StatusViewModel value)\n        {\n            if (element == null) throw new ArgumentNullException(nameof(element));\n\n            element.SetValue(StatusProperty, value);\n        }\n\n        private static int GetStatusToken(FrameworkElement element)\n        {\n            if (element == null) throw new ArgumentNullException(nameof(element));\n\n            return (int)element.GetValue(StatusTokenProperty);\n        }\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/Components/Status/Views/ToolTipHelper.cs#L6-L42","documentation":"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.","triggerScenarios":"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).","commonSituations":"Event handlers like ToolTipOpening where the source is unexpectedly null; control template lookups returning null; passing a DataContext instead of the FrameworkElement.","solutions":["Pass a valid FrameworkElement instance to GetStatus","Null-check the element (or the result of FindName/templated parent lookup) before calling GetStatus","Verify the caller is invoked from a WPF UI context where the element is fully loaded"],"exampleFix":"// before\nvar status = ToolTipHelper.GetStatus(someControl);\n// after\nvar status = someControl != null ? ToolTipHelper.GetStatus(someControl) : null;","handlingStrategy":"type-guard","validationCode":"if (element == null) return null; // or skip the GetStatus call","typeGuard":"bool HasStatus(FrameworkElement e) => e != null && ToolTipHelper.GetStatus(e) != null;","tryCatchPattern":"try { var status = ToolTipHelper.GetStatus(element); } catch (ArgumentNullException) { /* element was null; handle absence of status */ }","preventionTips":["Null-check elements returned by FindName/templated-parent lookups before use","Read attached properties only from loaded, live elements","Prefer null-conditional logic when tracing elements from events"],"tags":["wpf","null-argument","attached-property"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}