private static object CoerceMaxHeight(DependencyObject d, object value) { TabControlEx tc = (TabControlEx)d; double newValue = (double)value; if (newValue < tc.TabItemMinHeight) { return(tc.TabItemMinHeight); } return(newValue); }
private static object CoerceMinWidth(DependencyObject d, object value) { TabControlEx tc = (TabControlEx)d; double newValue = (double)value; if (newValue > tc.TabItemMaxWidth) { return(tc.TabItemMaxWidth); } return(newValue > 0 ? newValue : 0); }
private void Close(object o, RoutedEventArgs e) { TabControlEx tabControl = WpfExtensions.FindVisualParent <TabControlEx>(this); if (tabControl == null) { return; } tabControl.RemoveItem(this); //after remove the item from the tabcontrol,detach the hander from the click event this._closeButton.Click -= new RoutedEventHandler(Close); }
/// <summary> /// OnMinMaxChanged callback responds to any of the Min/Max dependancy properties changing /// </summary> /// <param name="d"></param> /// <param name="e"></param> private static void OnMinMaxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TabControlEx tc = (TabControlEx)d; if (tc.Template == null) { return; } foreach (TabItemEx child in tc.InternalChildren()) { if (child != null) { child.Dimension = null; } } if (tc._tabPanel != null) { tc._tabPanel.InvalidateMeasure(); } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); _tabControl = base.TemplatedParent as TabControlEx; }