{"record":{"id":"5a1909d44b15a85c","repo":"lepoco/wpfui","slug":"item-content-is-null","errorCode":null,"errorMessage":"Item content is null","messagePattern":"Item content is null","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs","lineNumber":167,"sourceCode":"        );\n        UpdateLastContainer();\n    }\n\n    private void ItemContainerGeneratorOnItemsChanged(object sender, ItemsChangedEventArgs e)\n    {\n        if (e.Action != NotifyCollectionChangedAction.Remove)\n        {\n            return;\n        }\n\n        UpdateLastContainer();\n    }\n\n    private void OnTemplateButtonClick(object? obj)\n    {\n        if (obj is null)\n        {\n            throw new ArgumentNullException(\"Item content is null\");\n        }\n\n        DependencyObject container = ItemContainerGenerator.ContainerFromItem(obj);\n        int index = ItemContainerGenerator.IndexFromContainer(container);\n\n        OnItemClicked(obj, index);\n    }\n\n    private void InteractWithItemContainer(int offsetFromEnd, Action<BreadcrumbBarItem> action)\n    {\n        if (ItemContainerGenerator.Items.Count <= 0)\n        {\n            return;\n        }\n\n        var item = ItemContainerGenerator.Items[^offsetFromEnd];\n        var container = (BreadcrumbBarItem)ItemContainerGenerator.ContainerFromItem(item);\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/lepoco/wpfui/blob/ffebacd61058170cf63864b7d5aa730cffff848a/src/Wpf.Ui/Controls/BreadcrumbBar/BreadcrumbBar.cs#L149-L185","documentation":"Thrown by BreadcrumbBar.OnTemplateButtonClick when the clicked item (obj) is null. The click handler resolves the container and index from the item, so a null item is treated as an invalid argument (ArgumentNullException) rather than silently ignored.","triggerScenarios":"A template button in the BreadcrumbBar fires its click command with a null payload, e.g. a Button whose CommandParameter is unset or bound to a null collection element. OnTemplateButtonClick receives null and throws.","commonSituations":"Custom BreadcrumbBar item templates where the button's CommandParameter is not wired to {Binding} of the item, a data source containing null entries, or an items-source reset that leaves a stale button bound to null.","solutions":["Ensure each BreadcrumbBar item template's clickable element passes the non-null item as its command parameter (CommandParameter=\"{Binding}\" or DataContext-based).","Filter null entries out of the ItemsSource before binding.","Avoid null items in the underlying collection; initialize items to non-null placeholders."],"exampleFix":"// before\n<Button Command=\"{Binding RelativeSource={RelativeSource AncestorType=ui:BreadcrumbBar}, Path=TemplateClickCommand}\" />\n\n// after\n<Button Command=\"{Binding RelativeSource={RelativeSource AncestorType=ui:BreadcrumbBar}, Path=TemplateClickCommand}\"\n        CommandParameter=\"{Binding}\" />","handlingStrategy":"validation","validationCode":"if (obj is null) { return; } // guard before OnTemplateButtonClick logic","typeGuard":"static bool IsValidBreadcrumbItem(object? o) => o is not null;","tryCatchPattern":null,"preventionTips":["Wire template button CommandParameter to the item (CommandParameter=\"{Binding}\").","Filter null entries from the ItemsSource.","Avoid stale buttons after items-source resets."],"tags":["breadcrumbbar","xaml","command","null-argument"],"backgroundTag":null,"analyzedSha":"ffebacd61058170cf63864b7d5aa730cffff848a","analyzedAt":"2026-08-13T21:36:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}