RelativeFontSize.cs 802 B

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