Ejemplo n.º 1
0
        private double ProvideCompactWidth(TabViewItem tab, object item, double availableWidth)
        {
            // If we're selected and have a value for that, then just return that.
            if (tab.IsSelected && !double.IsNaN(SelectedTabWidth))
            {
                return(SelectedTabWidth);
            }

            // Otherwise use min size.
            return(tab.MinWidth);
        }
Ejemplo n.º 2
0
        private double ProvideEqualWidth(TabViewItem tab, object item, double availableWidth)
        {
            if (double.IsNaN(SelectedTabWidth))
            {
                if (Items.Count <= 1)
                {
                    return(availableWidth);
                }

                return(Math.Max(tab.MinWidth, availableWidth / Items.Count));
            }
            else if (Items.Count() <= 1)
            {
                // Default case of a single tab, make it full size.
                return(Math.Min(SelectedTabWidth, availableWidth));
            }
            else
            {
                var width = (availableWidth - SelectedTabWidth) / (Items.Count - 1);

                // Constrain between Min and Selected (Max)
                if (width < tab.MinWidth)
                {
                    width = tab.MinWidth;
                }
                else if (width > SelectedTabWidth)
                {
                    width = SelectedTabWidth;
                }

                // If it's selected make it full size, otherwise whatever the size should be.
                return(tab.IsSelected
                    ? Math.Min(SelectedTabWidth, availableWidth)
                    : width);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TabClosingEventArgs"/> class.
 /// </summary>
 /// <param name="item">Item being closed.</param>
 /// <param name="tab"><see cref="TabViewItem"/> container being closed.</param>
 public TabClosingEventArgs(object item, TabViewItem tab)
 {
     Item = item;
     Tab  = tab;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TabDraggedOutsideEventArgs"/> class.
 /// </summary>
 /// <param name="item">data context of element dragged</param>
 /// <param name="tab"><see cref="TabViewItem"/> container being dragged.</param>
 public TabDraggedOutsideEventArgs(object item, TabViewItem tab)
 {
     Item = item;
     Tab  = tab;
 }
Ejemplo n.º 5
0
 private static void SetOriginalWidth(TabViewItem obj, double value)
 {
     obj.SetValue(OriginalWidthProperty, value);
 }
Ejemplo n.º 6
0
 // Attached property for storing widths of tabs if set by other means during layout.
 private static double GetOriginalWidth(TabViewItem obj)
 {
     return((double)obj.GetValue(OriginalWidthProperty));
 }