How to make a property readonly dynamically in code

Grids for WPF Forum

Posted 10 years ago by softeng
Avatar
Hello,

Is there any way to make a property readonly dynamically in c# source code without using xaml? I need to make a property readonly when the value of another property changes, but I need to do this dynamically in c# code.

Similarly, is there any way to show or hide a property dynamically in c# source code without using xaml?

Thanks.

Comments (1)

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

The answer to your first question largely depends on how you are using the PropertyGrid. Are you using PropertyGrid.SelectedObject(s), PropertyGrid.Properties, or PropertyGrid.Items/ItemsSource to populate the control? Are you using a custom data factory or data accessors?

Assuming you are using SelectObject(s), then this thread discusses how the IsReadOnly property can be hooked up so it can be changed during runtime:

http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=3957#14633

For your second question, the PropertyGrid has support for "filtering" using the DataFilter property. There is a QuickStart in our Sample Browser that shows this in action.

Alternatively, you could create a custom PropertyDataAccessor (like above for read-only) that has a IsVisible property and hook that up to the PropertyGridDataAccessorItem.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) 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.