Declined
Last Updated: 11 Aug 2021 15:47 by Petar
Vladimir
Created on: 04 Aug 2021 11:24
Category: TabControl
Type: Bug Report
1
TabControl: The DropDownContentTemplate is not applied to dynamically added items
The DropDownContentTemplate is not applied to items in the dropdown menu that are dynamically added. 
1 comment
Petar
Posted on: 11 Aug 2021 15:47

Reason for decline:

This is expected behavior. It is not a regression - because it used to work in the past due to incorrect matching logic which matches the properties of the first item in the dropdown with the first item of the tabstrip but they might different items obviously in the case when brand new item is added in the drop down items. The suggested workaround should be correct way to go:

   var itemSource = dropDownMenu.ItemsSource as System.Collections.ObjectModel.ObservableCollection<object>;

                if (itemSource.Count() > 1)
                {
                    var item = new MDITabHeader("[Close All Tabs]", Guid.Empty);
                    //re arrange the list so close all is at the end
                    itemSource.Insert(0, item);
                    var lastItemIndex = itemSource.Count() - 1;
                    itemSource.Move(0, lastItemIndex);

                    //workaround
                    var container = dropDownMenu.ItemContainerGenerator.ContainerFromItem(item) as RadMenuItem;
                    container.HeaderTemplate = (DataTemplate)TryFindResource("MDITabHeaderDataTemplate_Dropdown");
                }