عنوان:

‫کتابخانه‌ی CalcBinding برای WPF


نویسنده: وحید نصیری
تاریخ: ۱۳۹۴/۱۰/۰۷ ۱۶:۳۰
آدرس: www.dntips.ir
Before (Automatic inverse example):

<TextBox Text = "{Binding Path=A, Conveter={x:StaticResource MyMathConverter}">

public class MyMathConverter : IValueConverter
{
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
          var source = (int)value;
          return Math.Sin(source*2)-5;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {        
          var res = Double.Parse(value);
          return (int)(Math.Asin(res + 5) / 2);
        }
}

After:

<TextBox Text = "{c:Binding 'Math.Sin(A*2)-5'}">


مشاهده مطلب اصلی