public void BindText(Control control) { if (control.Tag != null) { PropertyInfo property = ViewModelType.GetProperty(control.Tag.ToString()); if (property != null) { string value = property.GetValue(ViewModel) as string; if (value != null) { SetText(control, value); } } } }
public void BindCheckedState(Control control) { if (control.Tag != null) { PropertyInfo valueProperty = ViewModelType.GetProperty(control.Tag.ToString()); if (valueProperty != null) { PropertyInfo checkStateProperty = control.GetType().GetProperty("CheckState"); if (checkStateProperty != null) { control.On("CheckStateChanged", (o, a) => valueProperty.SetValue(ViewModel, checkStateProperty.GetValue(control))); object checkState = valueProperty.GetValue(ViewModel); checkStateProperty.SetValue(control, checkState); } } } }
public void BindDataSource(Control control) { ListControl listControl = control as ListControl; if (listControl != null) { object tag = listControl.Tag; if (tag != null) { string tagString = tag.ToString(); PropertyInfo dataSrcProp = ViewModelType.GetProperty("{0}DataSource"._Format(tagString)) ?? ViewModelType.GetProperty("{0}List"._Format(tagString)); if (dataSrcProp != null) { listControl.DataSource = dataSrcProp.GetValue(ViewModel); } } } }