private void SetTabWidths() { if (TabHeaders.Count > 0) { Dispatcher.BeginInvoke(new Action(() => { double windowWidth = TabPanel.ActualWidth; double tabsWidth = GetTabPanelWidth(); if (tabsWidth > windowWidth) { var tabs = TabHeaders.ToList().OrderByDescending(x => x.ActualWidth).ToList(); double widestTab = tabs[0].ActualWidth; tabs = tabs.FindAll(x => x.ActualWidth >= widestTab); foreach (var tab in tabs) { double increment = (tabsWidth - windowWidth) / tabs.Count; int index = TabHeaders.ToList().FindIndex(x => x.Id == tab.Id); if (index >= 0) { var t = TabHeaders[index]; t.MaxWidth = Math.Max(TabHeader.MIN_WIDTH, t.ActualWidth - increment); } tabsWidth = GetTabPanelWidth(); } } else if (tabsWidth < windowWidth) { var tabs = TabHeaders.ToList().OrderByDescending(x => x.ActualWidth).ToList(); double widestTab = tabs[0].ActualWidth; tabs = tabs.FindAll(x => x.ActualWidth >= widestTab); foreach (var tab in tabs) { double increment = (windowWidth - tabsWidth) / tabs.Count; int index = TabHeaders.ToList().FindIndex(x => x.Id == tab.Id); if (index >= 0) { var t = TabHeaders[index]; double width = t.MaxWidth + increment; width = Math.Max(width, TabHeader.MIN_WIDTH); width = Math.Min(width, TabHeader.MAX_WIDTH); t.MaxWidth = width; } tabsWidth = GetTabPanelWidth(); } } }), System.Windows.Threading.DispatcherPriority.Background, new object[] { }); } }
public TabHeader FindTab(string name, string tag = null) { int index = TabHeaders.ToList().FindIndex(x => x.Text == name && x.Tag == tag); if (index >= 0) { return(TabHeaders[index]); } return(null); }
public TabHeader FindTab(IPage page, string name = null, string tag = null) { string title = page.Title; if (name != null) { title = name; } int index = TabHeaders.ToList().FindIndex(x => x.Text == title && x.Tag == tag); if (index >= 0) { return(TabHeaders[index]); } return(null); }
public int FindTabIndex(TabHeader header) { int index = TabHeaders.ToList().FindIndex(x => x.Text == header.Text); return(index); }
public int FindTabIndex(string name, string tag = null) { int index = TabHeaders.ToList().FindIndex(x => x.Text == name && x.Tag == tag); return(index); }