void SwitchToNextVisibleTab() { Ribbon rbn = IRibbonControl.GetParentRibbon(this); if ((rbn != null) && ((IAvaloniaList <object>)Items).Contains(rbn.SelectedItem)) { int selIndex = rbn.SelectedIndex; rbn.CycleTabs(false); if (selIndex == rbn.SelectedIndex) { rbn.CycleTabs(true); } } /*var selectableItems = ((IAvaloniaList<object>)rbn.Items).OfType<RibbonTab>().Where(x => x.IsVisible && x.IsEnabled); * RibbonTab targetTab = null; * foreach (RibbonTab tab in selectableItems) * { * if (((IAvaloniaList<object>)Items).Contains(tab)) * break; * * targetTab = tab; * } * * if (targetTab == null) * { * selectableItems = selectableItems.Reverse(); * * foreach (RibbonTab tab in selectableItems) * { * if (((IAvaloniaList<object>)Items).Contains(tab)) * break; * * targetTab = tab; * } * } * int index = ((IAvaloniaList<object>)rbn.Items).IndexOf(targetTab); * rbn.SelectedIndex = index; * //if (index > 0) */ }