We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use CustomEditor with Dynamic Properties for Propertygrid

Thread ID:

Created:

Updated:

Platform:

Replies:

148447 Oct 20,2019 03:21 PM UTC Oct 31,2019 04:56 PM UTC WPF 6
loading
Tags: PropertyGrid
Kevin Bushe
Asked On October 20, 2019 03:21 PM UTC

Hi,

    I have been trying to use a custom editor to dynamic properties unsuccessfully.  Using the example given on thread https://www.syncfusion.com/forums/147525/dynamic-properties-for-propertygrid-at-runtime as a starting point I wanted to change one of the properties value type to a List<string> then use a CustomEditor to apply a combobox with the values in the List.  Unfortunately,  the function "public object Create(PropertyInfo propertyInfo)" on ITypeEditor is passing in a null for propertyInfo so an editor can not be applied to the property.   Here us the initialization code:


            string candidateName = "John";
            int age = 30;


            _CanididateDetails.Values.Add("Name", candidateName);
            _CanididateDetails.Values.Add("Address", new List<string>() { "A", "B" });
            _CanididateDetails.Values.Add("Age", age);

            this.propertyGrid.SelectedObject = _CanididateDetails;

            CustomEditor comboeditor = new CustomEditor() { HasPropertyType = true, PropertyType = typeof(List<string>), Editor = new ComboEditor() };

            comboeditor.Properties.Add("Address");

            propertyGrid.CustomEditorCollection.Add(comboeditor);

            propertyGrid.RefreshPropertygrid();

Error happens here:


I have attached an example as well.

Any help would be great!


Attachment: PropertyGrid_Example_b8f8e131.zip

Kanniyappan Panneer Selvam [Syncfusion]
Replied On October 21, 2019 12:55 PM UTC

Hi Kevin Bushe, 
 
Thanks for contacting Syncfusion support. 
 
We were able to see the reported issue at our end and we will check and update you the further details on October 22nd , 2019. 
 
We appreciate your patience until then. 
 
Regards, 
Kanniyappan P 


Kanniyappan Panneer Selvam [Syncfusion]
Replied On October 22, 2019 01:13 PM UTC

Hi Kevin Bushe, 
 
Sorry for the delay. 
 
Currently we are validating the reported issue and update you the further details on October 24th, 2019. 
 
We appreciate your patience until then. 
 
Regards, 
Kanniyappan P 


Kanniyappan Panneer Selvam [Syncfusion]
Replied On October 23, 2019 01:22 PM UTC

Hi Kevin Bushe,  
 
Thanks for your patience. 
 
We have checked your reported behavior and this occurred because PropertyInfo is not available for dynamic properties which class type is the ICustomTypeDescriptor . We've prepared a sample to achieve your requirement. In this sample, dynamic object values are updated using the propertyItem instead of PropertyInfo. We plan to provide support for this type of dynamic properties in any of our upcoming release. Meanwhile, we suggest that you use the work-around to meet your requirements. Please find the sample for the same from below. 
 
Code Snippet: 
 
public void Attach(PropertyViewItem property, PropertyItem info
        { 
            var binding = new Binding("Value"
            { 
                Mode = BindingMode.TwoWay, 
                Source = info, 
                ValidatesOnExceptions = true
                ValidatesOnDataErrors = true 
            }; 
            BindingOperations.SetBinding(combo, ComboBox.SelectedItemProperty, binding); 
            dynamic list = info.Value
            foreach (dynamic v in list) 
            { 
                combo.Items.Add(v); 
            } 
            combo.SelectedIndex = 0; 
        } 
 
Screenshot: 
 
 
 
 
Regards, 
Kanniyappan P 
  


Kevin Bushe
Replied On October 28, 2019 04:45 PM UTC

Hi Kanniyappan,

        Thank you for the outstanding support.   The example you provided works great.

Regards,
Kevin

Kanniyappan Panneer Selvam [Syncfusion]
Replied On October 29, 2019 11:54 AM UTC

Hi Kevin Bushe,  
  
Thanks for you update.  
  
We are glad to know that the reported issue has been resolved at your end. Please let us know if you need any further assistance on this. We are happy to help you.  
 
And currently we are validating your requirement as feature request and update you the further details on October 30th , 2019. 
  
Regards,  
Kanniyappan P 


Kanniyappan Panneer Selvam [Syncfusion]
Replied On October 31, 2019 04:56 PM UTC

Hi Kevin Bushe, 
    
Thanks for your patience.   
    
We have logged the feature request on your requirement and it can be tracked through our feedback portal below.    
    
   
The feature will be available in any of our upcoming releases. 

Regards, 
Kanniyappan P  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon