This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I am evaluating a trial version of PropertyGrid. I need to make some properties not editable in PropertyGrid. How could I do that? Thanks. |
|
|
Apply the attribute [ReadOnly(true)], or, for more flexibility in controlling the appearance, use a PropertyEditor declaration to map them to a read-only DataTemplate. |
|
|
Thanks, Ivan. How could specify the readonly attribute dynamically in the code, after the properygrid has been displayed? |
|
|
That's a bit trickier. The canonical way to do this is by implementing a TypeConverter (and the GetProperties method) or ICustomTypeDescriptor, but these can be a bit heavyweight. The alternative is to implement a custom editor where the data template can be switched between read-write and read-only, e.g. using a DataTrigger (you can use {Binding Node} to get at the metadata). Here's an example of enabling/disabling a property based on another property, which you could adapt: http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1335 |
|
|
Is there an easy way to make the properties enabled or disabled in the code without using data template in xaml? For example, use function like this EnableProperty("PropertyName"). If not, would you like to implement it in the next version of PropertyGrid. |
|
|
There's not currently any function along the lines of EnableProperty, but I've logged a feature request for it -- thanks for the suggestion! |
|