private void filed_changed(object sender, SelectionChangedEventArgs e) { var controlop = new ControlAndOperator(); var pinfo = field_cb.SelectedValue as PropertyInfo; var ctlcontext = new FormItemContext(_type, pinfo); controlop.InputControl = InputControlBuilder.CreateControl(ctlcontext); if (pinfo.PropertyType.Name.Equals("string", StringComparison.OrdinalIgnoreCase)) { controlop.UseStringOperator = true; } else { controlop.UseNumberOperator = true; } if (CreateControlCallback != null) { controlop = CreateControlCallback(ctlcontext, controlop); } _bindobject = Activator.CreateInstance(_type); controlop.InputControl.DataContext = _bindobject; input_br.Child = controlop.InputControl; operator_cb.ItemsSource = null; if (controlop.UseStringOperator) { operator_cb.ItemsSource = EnumNameValuePair.EnumToList(typeof(StringOperator)); } else if (controlop.UseNumberOperator) { operator_cb.ItemsSource = EnumNameValuePair.EnumToList(typeof(NumberOperator)); } operator_cb.SelectedIndex = 0; if (pinfo.PropertyType.IsEnum) { operator_cb.IsEnabled = false; } else { operator_cb.IsEnabled = true; } }
private void filed_changed(object sender, SelectionChangedEventArgs e) { var controlop = new ControlAndOperator(); var pinfo=field_cb.SelectedValue as PropertyInfo; var ctlcontext = new FormItemContext(_type, pinfo); controlop.InputControl= InputControlBuilder.CreateControl(ctlcontext); if (pinfo.PropertyType.Name.Equals("string", StringComparison.OrdinalIgnoreCase)) { controlop.UseStringOperator = true; } else controlop.UseNumberOperator = true; if (CreateControlCallback != null) controlop = CreateControlCallback(ctlcontext, controlop); _bindobject = Activator.CreateInstance(_type); controlop.InputControl.DataContext = _bindobject; input_br.Child = controlop.InputControl; operator_cb.ItemsSource = null; if (controlop.UseStringOperator) operator_cb.ItemsSource = EnumNameValuePair.EnumToList(typeof(StringOperator)); else if (controlop.UseNumberOperator) operator_cb.ItemsSource = EnumNameValuePair.EnumToList(typeof(NumberOperator)); operator_cb.SelectedIndex = 0; if (pinfo.PropertyType.IsEnum) { operator_cb.IsEnabled = false; }else { operator_cb.IsEnabled = true; } }