TabSizeConverter.cs 923 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. namespace MECF.Framework.UI.Core.Converters
  9. {
  10. public class TabSizeConverter : IMultiValueConverter
  11. {
  12. public object Convert(object[] values, Type targetType, object parameter,
  13. System.Globalization.CultureInfo culture)
  14. {
  15. TabControl tabControl = values[0] as TabControl;
  16. double width = (int)(tabControl.ActualWidth / tabControl.Items.Count);
  17. //Subtract 1, otherwise we could overflow to two rows.
  18. return (width <= 1) ? 0 : (width - 3);
  19. }
  20. public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
  21. System.Globalization.CultureInfo culture)
  22. {
  23. throw new NotSupportedException();
  24. }
  25. }
  26. }