Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1.     class ScalingConverter : IValueConverter
  2.     {
  3.         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  4.         {
  5.             if (value == null || parameter == null)
  6.                 return DependencyProperty.UnsetValue;
  7.             double v = (double)value;
  8.             double p = (double)parameter;
  9.             return v * p;
  10.         }
  11.  
  12.         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  13.         {
  14.             throw new NotSupportedException();
  15.         }
  16.     }
  17.  
  18.     public class DoubleExtension : TypedValueExtension<double>
  19.     {
  20.         public DoubleExtension(double value) : base(value) { }
  21.     }
  22.  
  23.     public class TypedValueExtension<T> : MarkupExtension
  24.     {
  25.         public TypedValueExtension(T value) { Value = value; }
  26.         public T Value { get; set; }
  27.         public override object ProvideValue(IServiceProvider sp) { return Value; }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement