/// <summary> /// remove a tabItem /// </summary> /// <param name="tabItem"></param> public void RemoveItem(TabItemEx tabItem) { var c = new TabItemExCancelEventArgs(tabItem); TabItemClosing.SafeFire(new object[] { c }); //if the itemssource is using if (this.ItemsSource != null) { IList list = this.ItemsSource as IList; if (list == null) { return; } //get the data item var item = ItemContainerGenerator.ItemFromContainer(tabItem); if (item == null) { return; } list.Remove(item); } else { this.Items.Remove(tabItem); } TabItemClosed.SafeFire(new object[] { c }); }
private static void SetDimensions(TabItemEx tabItem) { if (tabItem.Dimension == null) { tabItem.Dimension = new Dimension { Height = tabItem.Height, Width = tabItem.Width, MinHeight = tabItem.MinHeight, MaxHeight = tabItem.MaxHeight, MinWidth = tabItem.MinWidth, MaxWidth = tabItem.MaxWidth }; } else { tabItem.BeginInit(); tabItem.Height = tabItem.Dimension.Height; tabItem.MinHeight = tabItem.Dimension.MinHeight; tabItem.MaxHeight = tabItem.Dimension.MaxHeight; tabItem.Width = tabItem.Dimension.Width; tabItem.MinWidth = tabItem.Dimension.MinWidth; tabItem.MaxWidth = tabItem.Dimension.MaxWidth; tabItem.EndInit(); } }
public Size MeasureVertical(Size availableSize) { int childCount = base.InternalChildren.Count; double extentHeight = 0d; double[] heights = new double[childCount]; for (int i = 0; i < childCount; i++) { TabItemEx tabItem = base.InternalChildren[i] as TabItemEx; if (tabItem == null) { return(new Size()); } SetDimensions(tabItem); tabItem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); ClearDimensions(tabItem); //caculate the max item width recursively _maxItemWidth = Math.Max(_maxItemWidth, Math.Ceiling(tabItem.DesiredSize.Width)); //caculate this tabitem's wdith while respecting the max and min width constraints var itemHeight = Math.Max(this.MinimumChildHeight, Math.Min(this.MaximimChildHeight, Math.Ceiling(tabItem.DesiredSize.Height))); heights[i] = itemHeight; //cacualte the total horitantal width extentHeight += itemHeight; } //caculate the max child height finally while respecting the max and min widtt constraints _maxItemWidth = Math.Max(this.MinimumChildWidth, Math.Min(this.MaximumChildWith, _maxItemWidth)); this._extent = new Size(extentHeight, _maxItemWidth); if (extentHeight <= availableSize.Height) { MeasureVerticalFitted(childCount, heights); } else { if (!MeasureVerticalUniform(availableSize, childCount, heights)) { MeasureVerticalPageing(availableSize, childCount, heights); } } return(new Size(_maxItemWidth, double.IsInfinity(availableSize.Height)?_extent.Height:availableSize.Height)); }
public TabItemExCancelEventArgs(TabItemEx item) { TabItem = item; }
public TabItemExEventArgs(TabItemEx item) { TabItem = item; }