public static T Bind <T, S>(this T bindable, DependencyProperty property, S source, Expression <Func <S, object> > sourcePath, IValueConverter converter) where T : DependencyObject { BindingOperations.SetBinding(bindable, property, new Binding(RouteVisitor.GetRoute(sourcePath)) { Source = source, Converter = converter }); return(bindable); }
static ConstantExpression GetPathConstant(Expression expression) { if (expression.NodeType == ExpressionType.Quote) { expression = ((UnaryExpression)expression).Operand; } if (expression.NodeType != ExpressionType.Lambda) { throw new InvalidOperationException(); } string str = RouteVisitor.GetRoute((LambdaExpression)expression); return(Expression.Constant(str)); }
public static T Bind <T, S>(this T bindable, DependencyProperty property, Expression <Func <S, object> > sourcePath) where T : DependencyObject { BindingOperations.SetBinding(bindable, property, new Binding(RouteVisitor.GetRoute(sourcePath))); return(bindable); }