protected internal void RemoveTabButton(TabButton tabButton) { if (tabButton == null) { throw new ArgumentNullException(nameof(tabButton), "tabButton should not be null."); } if (tabButtons.Contains(tabButton) == false) { throw new ArgumentException("tabButton does not exist in TabBar.", nameof(tabButton)); } int index = tabButtons.IndexOf(tabButton); TabButton selectedTabButton = tabButtons[SelectedIndex]; tabButtons.Remove(tabButton); Remove(tabButton); tabButtonGroup.Remove(tabButton); if ((index < SelectedIndex) || (tabButtons.Count == SelectedIndex)) { SelectedIndex -= 1; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } } if ((SelectedIndex != -1) && (selectedTabButton != tabButtons[SelectedIndex])) { tabButtons[SelectedIndex].IsSelected = true; } }
protected internal void RemoveTabButton(TabButton tabButton) { if (tabButton == null) { throw new ArgumentNullException(nameof(tabButton), "tabButton should not be null."); } if (tabButtons.Contains(tabButton) == false) { throw new ArgumentException("tabButton does not exist in TabBar.", nameof(tabButton)); } int index = tabButtons.IndexOf(tabButton); TabButton selectedTabButton = tabButtons[SelectedIndex]; tabButtons.Remove(tabButton); Remove(tabButton); tabButtonGroup.Remove(tabButton); if ((index < SelectedIndex) || (tabButtons.Count == SelectedIndex)) { SelectedIndex -= 1; if (TabButtonSelected != null) { TabButtonSelectedEventArgs args = new TabButtonSelectedEventArgs(SelectedIndex); TabButtonSelected(this, args); } } if ((SelectedIndex != -1) && (selectedTabButton != tabButtons[SelectedIndex])) { tabButtons[SelectedIndex].IsSelected = true; tabButtons[SelectedIndex].SetTabButtonState(ControlState.Pressed); } //TODO: To support non-unified tab button size. CalculateUnifiedTabButtonSize(); }