Difference between PropertyEditor and PropertyControl?

Nov 25, 2011 at 9:36 AM

I recently had to change my PropertyEditors to PropertyControls to make INotifyPropertyChanged.PropertyChanged events through NotifyPropertyWeaver, work. This raised the question to, what exactly is the difference between PropertyEditor and PropertyControl? AFAIK I can see they both do about the same.

BTW, I think there's a smal inconsistency between the two. PropertyEditor has a ShowTabs property, while PropertyControl has UseTabs.

/ Jimmy

Nov 26, 2011 at 7:05 PM

hi Jimmy, 

PropertyEditor is based on templates. The controls in the templates binds to an intermediate "PropertyViewModel", which uses reflection to get/set the values on your (View)Model.

PropertyControl is programmatically creating the controls, and creates bindings directly to your (View)Model. I think this is more efficient, and also easier to customize than the templates.

I'll add documentation when the controls have stabilized more. Development is focused on the PropertyControl from now.

Yes, I renamed to UseTabs in PropertyControl, don't know if it is better or not - naming properties is always difficult. Also note that the SelectedObjects is not available in PropertyControl (create an ItemsBag on SelectedObject instead).

Jan 3, 2012 at 9:11 PM

One of the things I like about PropertyEditor is I can call PropertyEditor.CreatePropertyModel to obtain the model the editor is using. This is very useful when I want to make a report, because the CreatePropertyModel orders everything the way it is displayed on the screen, slotting each property into its category and tab, and even takes care of translations. I can use that to create a report that matches the screen(s).

Will PropertyControl afford me similar access?

Jan 3, 2012 at 9:17 PM
Edited Jan 3, 2012 at 9:17 PM

Yes, the PropertyItemFactory is creating a hierarchic model that can be used to create a report. The model is currently not exposed as a property, but can easily be regenerated by the PropertyItemFactory.CreateModel method. See the code in the PropertyControls.UpdateControls() method.