{"record":{"id":"7897befa25787e78","repo":"cefsharp/CefSharp","slug":"replace-not-implemented-yet","errorCode":null,"errorMessage":"Replace not implemented yet","messagePattern":"Replace not implemented yet","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"CefSharp.Wpf.Example/Controls/NonReloadingTabControl.cs","lineNumber":95,"sourceCode":"                    {\n                        foreach (var item in e.OldItems)\n                        {\n                            var cp = FindChildContentPresenter(item);\n                            if (cp != null)\n                            {\n                                itemsHolderPanel.Children.Remove(cp);\n                            }\n                        }\n                    }\n\n                    // Don't do anything with new items because we don't want to\n                    // create visuals that aren't being shown\n\n                    UpdateSelectedItem();\n                    break;\n\n                case NotifyCollectionChangedAction.Replace:\n                    throw new NotImplementedException(\"Replace not implemented yet\");\n            }\n        }\n\n        protected override void OnSelectionChanged(SelectionChangedEventArgs e)\n        {\n            base.OnSelectionChanged(e);\n            UpdateSelectedItem();\n        }\n\n        private void UpdateSelectedItem()\n        {\n            if (itemsHolderPanel == null)\n            {\n                return;\n            }\n\n            // Generate a ContentPresenter if necessary\n            var item = GetSelectedTabItem();","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Wpf.Example/Controls/NonReloadingTabControl.cs#L77-L113","documentation":"Thrown by the example NonReloadingTabControl.OnItemsChanged when the underlying ObservableCollection raises a Replace action. This custom TabControl keeps all tabs alive (non-reloading) by managing ContentPresenters manually; it handles Reset/Add/Remove but explicitly has not implemented Replace, so replacing an item in the bound collection throws NotImplementedException.","triggerScenarios":"Replacing an element in the ObservableCollection bound to NonReloadingTabControl.Items, e.g. `tabs[0] = newTab` or assigning by index; an observable collection whose source performs replace operations.","commonSituations":"Swapping a tab's view model in place; using ObservableCollection<T>[i] = value; a refresh pattern that replaces items rather than clearing and re-adding.","solutions":["Avoid Replace semantics on the bound collection: instead Remove then Add, or Clear then re-populate, which this control handles.","If you must replace, remove the old item and insert the new one at the same index.","Subclass NonReloadingTabControl and implement the Replace case by removing the old ContentPresenter and creating one for the new item.","Switch to a standard TabControl if Replace support is essential and you do not need the non-reloading behavior."],"exampleFix":"// before\ntabs[0] = new BrowserTabViewModel(url); // throws NotImplementedException\n\n// after\nvar old = tabs[0];\ntabs.Remove(old);\ntabs.Insert(0, new BrowserTabViewModel(url));","handlingStrategy":"fallback","validationCode":"// Avoid Replace on collections bound to NonReloadingTabControl.\n// Use Remove + Insert instead of index assignment:\ntabs.Remove(oldItem);\ntabs.Insert(index, newItem);","typeGuard":null,"tryCatchPattern":"try { tabs[0] = newItem; }\ncatch (NotImplementedException) { tabs.Remove(tabs[0]); tabs.Insert(0, newItem); }","preventionTips":["Never use index assignment (Replace) on the bound ObservableCollection; use Remove+Insert.","If Replace is essential, subclass NonReloadingTabControl and implement the Replace case.","Use a standard TabControl if you need full collection semantics."],"tags":["cefwsharp","wpf","example","tabcontrol","notimplemented"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}