There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
Suggestion: New feature:-> Support for adding custom properties to any View-Model classes at runtime
I am suggesting this feature because i think this can be very useful for many developers. Recently we had a requirement to add properties to view-model classes at run-time and those properties should be
bindable to the view-model controls.
For this we had to modify the ViewModel class of Code.framework. Changes are as follows:
(1)Inherited ViewModel class from 'CustomTypeDescriptor' (exists in System.ComponentModel namespace)
(2)Added new class 'CustomPropertyDescriptor' to the project which extends the PropertyDescriptor class
(3)Added a private list _myProperties of List<PropertyDescriptor> type (this too belongs to above namespace) to hold custom properties
(4)Overridden the 'GetProperties()' method to return return real properties along with custom properties (WPF data-binding calls this method)
(5)Added public methods 'AddProperty', 'GetPropertyValue', 'SetPropertyValue' etc. for access custom properties
(6)Also added 'CustomProperties' property to expose collection of custom properties & a method 'RemoveAllCustomProperties' to clear all custom properties.
I have attached modified 'ViewModel.cs' class (which is based on the latest version 4.0.41021.0) and a new class 'CustomPropertyDescriptor.cs'
Please let me know if any additional information is required regarding these changes/feature.
I hope you find these changes useful & will be delighted to see them included in the next version of Code.framework!
Thanks & Regards,