Set custom CategoryName and Description for CustomFactory.

Grids for WPF Forum

Posted 9 years ago by Sasha
Version: 14.2.0610
Avatar

Hi,

I've created Custom factory(like in tutorial) for my propertyGrid and it's working good:

 protected override IList<IPropertyDataAccessor> GetProperties(object value, DataFactoryOptions options)
 {
     IList<IPropertyDataAccessor> dataAccessors;

     var room = value as CustomDocumentWindowViewModel;
     if (room != null)
     {
         // Create a list of property data accessor results
         dataAccessors = new List<IPropertyDataAccessor>();

         // Add room name
         dataAccessors.Add(new CustomPropertyDataAccessor<CustomDocumentWindowViewModel, string>(room, o => o.Title, (string)Application.Current.Resources["TabName"], null));

         // Add room image path
         dataAccessors.Add(new CustomPropertyDataAccessor<CustomDocumentWindowViewModel, string>(room, o => o.ImagePath, (string)Application.Current.Resources["ImagePath"], null));
     }
     else
     {
         // Fall back to using the base method's results for nested objects
         dataAccessors = base.GetProperties(value, options);
     }

     return dataAccessors;
 }

 But also I would like to set Category and Description for each property. Setting via attribute [Category("")] is not working. I am not sure how should I do that. Can you please explain, what should I do or give me a link, where I can see some example.

Thanks you.

Comments (1)

Answer - Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

If you are using the CustomPropertyDataAccessor from our CustomFactory QuickStart, the easiest way to add a category/description would be to override CategoryInternal and DescriptionInternal similar to how we do the DisplayNameInternal override.  Then also accept those values in the constructor like we do with 'displayName'.  Store the category and description in fields (like with displayName) and return them in the CategoryInternal and DescriptionInternal overrides.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.