public static Bounded Create <T>(string propertyName, int defaultValue) { var typeDescriptor = ViewModelDescriptor.GetTypeDescriptor(typeof(T)); var property = typeDescriptor.GetProperty(propertyName); var bounded = new Bounded(defaultValue, property.Bounded.GetItems()); return(bounded); }
public static string GetBoundText <T, TValue>(T item, Expression <Func <T, TValue> > func) { var memberExpr = func.Body as MemberExpression; ViewModelDescriptor t = ViewModelDescriptor.GetTypeDescriptor(typeof(T)); PropertyDescriptor property = t.Properties.First(x => x.PropertyName == memberExpr.Member.Name); return(property.ValueConverter.ConvertTo(property.GetValue(item))); }