private void PropertyGrid_AutoGeneratingPropertyGridItem(object sender, Syncfusion.Windows.PropertyGrid.AutoGeneratingPropertyGridItemEventArgs e)
        {
            if (e.OriginalSource is PropertyItem {
            } propertyItem)
            {
                if (DataContext is RedCollectionEditorViewModel viewModel)
                {
                    var propertyType = propertyItem.PropertyType;
                    var propertyName = propertyItem.DisplayName;

                    ITypeEditor customEditor = null;

                    if (propertyType == typeof(object) && propertyName.Equals("Element"))
                    {
                        var type = viewModel.SelectedElement.Element.GetType();
                        customEditor = PropertyGridEditors.GetPropertyEditor(type);
                    }
                    else
                    {
                        customEditor = PropertyGridEditors.GetPropertyEditor(propertyItem.PropertyType);
                    }

                    if (customEditor is not null)
                    {
                        propertyItem.Editor = customEditor;
                        e.ExpandMode        = PropertyExpandModes.FlatMode;
                    }
                }
            }
        }
Beispiel #2
0
        private void Propertygrid_AutoGeneratingPropertyGridItem(object sender, Syncfusion.Windows.PropertyGrid.AutoGeneratingPropertyGridItemEventArgs e)
        {
            if (e.DisplayName == "FirstName")
            {
                e.DisplayName = "First Name";
                e.Description = "First Name of the actual person.";
                e.Order       = 1;
                e.Category    = "Identity";
            }
            else if (e.DisplayName == "LastName")
            {
                e.DisplayName = "Last Name";
                e.Description = "Last Name of the actual person.";
                e.Order       = 2;
                e.Category    = "Identity";
            }
            else if (e.DisplayName == "MaritalStatus")
            {
                e.Order  = 6;
                e.Cancel = true;
            }
            else if (e.DisplayName == "Bank")
            {
                e.ExpandMode  = PropertyExpandModes.NestedMode;
                e.Description = "Bank in which the person has account.";
                e.Order       = 9;
                e.Category    = "Additional Info";
            }
            else if (e.DisplayName == "Email")
            {
                e.DisplayName = "Email ID";
                e.Description = "Email address of the actual person.";
                e.Order       = 11;
                e.Category    = "Additional Info";
            }
            else if (e.DisplayName == "Age")
            {
                e.Description = "Age of the actual person.";
                e.Order       = 5;
                e.Category    = "Identity";
            }
            else if (e.DisplayName == "DOB")
            {
                e.DisplayName = "Date of Birth";
                e.Description = "Birth date of the actual person.";
                e.Order       = 3;
                e.ExpandMode  = PropertyExpandModes.FlatMode;
                e.Category    = "Identity";
            }
            else if (e.DisplayName == "Gender")
            {
                e.Description = "Gender information of the actual person.";
                e.Order       = 4;
                e.Category    = "Identity";
            }
            else if (e.DisplayName == "FavoriteColor")
            {
                e.DisplayName = "Favorite Color";
                e.Description = "Favorite color of the actual person.";
                e.Order       = 7;
                e.Category    = "Additional Info";
            }
            else if (e.DisplayName == "IsPermanent")
            {
                e.DisplayName = "Permanent Employee";
                e.Description = "Determines whether the person is permanent or not.";
                e.Order       = 8;
                e.Category    = "Additional Info";
            }
            else if (e.DisplayName == "Key")
            {
                e.Cancel = true;
            }
            else if (e.DisplayName == "ID")
            {
                e.Description = "ID of the actual person.";
                e.Order       = 0;
                e.Category    = "Identity";
            }

            else if (e.DisplayName == "Country")
            {
                e.Description = "Country where the actual person is located.";
                e.Order       = 11;
                e.Category    = "Additional Info";
            }
            else if (e.DisplayName == "Mobile")
            {
                e.DisplayName = "Mobile Number";
                e.Description = "Contact Number of the actual person.";
                e.Order       = 13;
                e.Category    = "Additional Info";
            }
        }