Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have developed a prototype framework (MVVM) where control on the form is bound to a model property using a naming convention and its UI behavior is controlled using custom attributes.

  1. As of now the control name is divided into two parts - 3 part prefix and then the Name of the property in model to bind to.

    For eg txtFirstName textbox is bound to FirstName in model. During construction/load, all controls are looped through -

    BaseEdit baseEdit = (BaseEdit) control;
    baseEdit.DataBindings.Add("EditValue", viewModelBindingSource,
                              baseEdit.Name.Remove(0, 3),
                              true, DataSourceUpdateMode.OnPropertyChanged);
    

    There are some other attributes such as [ReadOnly], [Unbound] which are used to control the UI behavior.

    baseEdit.Properties.ReadOnly = Util.GetReadOnlyAttributeValue(
        control.Name.Remove(0, 3), viewModel.GetType());
    

    I am thinking of doing the looping the other way around, ie the Model properties, using a Bound attribute. Bound[ControlName, PropertyName]

    Bound["txtFirstName", "EditValue"]
    FirstName
    
  2. All the dropdown type controls, combobox, dropdown, checkeddropdown etc are autofilled by using a 'Key' from their tag property.

    if (control.GetType() == typeof(LookUpEdit) && 
        !string.IsNullOrEmpty(Convert.ToString(control.Tag))) //Exact match
    {
           LookUpEdit lookUpEdit = (LookUpEdit)control;
           DataBinding.InitializeLookUpEdit(lookUpEdit, lookUpEdit.Tag.ToString()); 
    }
    

    I took the biggest data-entry form with around 45 controls and tested the framework.

Is the above approach suitable for a big project? Any suggestions for improving the framework?

share|improve this question
Do you have a sample project so that it can be tested? – threeFourOneSixOneThree May 16 at 9:55

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.