Re: Custom property grid, need help

Grids for WPF Forum

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

Yes, this is possible. Your best bet would be to use a custom PropertyGrid.DataFilter. The Filters (Custom) QuickStart shows a category (i.e. ICategoryDataAccessor) can be filtered, but the same concept applies to properties (i.e. IPropertyDataAccessor). You can check the IPropertyDataAccessor.Target property to see if the property is associated with a Button/etc.

Alterntively, you can use a custom PropertyGrid.DataFactory (which derives from our TypeDescriptorFactory). In this case, you are filtering at the data level, while the DataFilter filters at the UI level. You would want to override the GetProperties(object,DataFactoryOptions) method, call the base version, then remove any properties you do not want to show from the list returned.

If you never want to show the filtered properties, then it's probably better to go with a custom DataFactory. If you want to selectively show/hide properties (based on user interaction) then the DataFilter is the better way to go.


Actipro Software Support

Comments (5)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sorry, online we only accept credit cards. If you are not able to use those, we can arrange for a postal-mailed check. You can e-mail our sales department for assistance if you choose to use that option.


Actipro Software Support

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

As I mentioned before, we already have a sample that shows how to apply custom filtering in our Sample Browser. It's titlted "Filters (Custom)" and is located under the PropertyGrid section. Please re-read the notes from our previous reply on how to alter the sample for your desired scenario.


Actipro Software Support

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

You would probably want to include a List<string> for each type whose properties you do not want to filter (i.e. Button). Then in the Filter method, check the type of IPropertyDataAccessor.Target and chose the appropriate list. Once you have the list, you can see if IPropertyDataAccessor.ValueName is in the list. If it is, then would return false (which says you don't want to filter it). If it isn't in the list, then you'd return true (which says you want to filter it).

Alternatively, you can a Dictionary<Type, List<string>> which would allow to more easily add new types, without having to change your Filter method.


Actipro Software Support

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

We can mark down a TODO item to add a sample like that in the future. Unfortunately, we have to prioritize all customer requests and there are several higher priority items we'd have to complete first.

You can bump up the priority of the TODO item by contracting for our time. This has worked out well for customers in the past, when our priorities did not align. You can find more information and submit a contracting request here.

Which part is confusing? You can get the type from IPropertyDataAccessor.Target, so that tells you if it's a Button. You can get the name of the property from IPropertyDataAccessor.ValueName, like you do above. You just need to build a List<string> of the properties in the class that has the Filter method and check that to determine if a property should be filtered. As I said, you'd need one per type (i.e. List<string> buttonProperties).


Actipro Software Support

Posted 9 years ago by Larsen - N/A, n/a
Avatar
Ok, plase delete this post.
The latest build of this product (v2019.1 build 0682) was released 27 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.