RelativeFontSize.cs 816 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. namespace InABox.WPF
  5. {
  6. public class RelativeFontSize : IValueConverter
  7. {
  8. // Create a ratio property
  9. // allows the converter to be used for different font ratios
  10. public double Ratio { get; set; }
  11. public object Convert(object value, Type targetType, object parameter,
  12. CultureInfo culture)
  13. {
  14. // add input parameter testing as needed.
  15. var originalFontSize = (double)value;
  16. var alteredFontSize = originalFontSize * Ratio;
  17. return alteredFontSize;
  18. }
  19. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  20. {
  21. throw new NotImplementedException();
  22. }
  23. }
  24. }