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 would like to provide my own editors. Specifically I would like to change the look of the combobox used in the editing of different lists. However, I would like to be able to do this without having to use the DeclaringType or PropertyName as in your example "Styling a built-in editor". I would like it to be used by default as the propertygrid currently decides which editor to use. Especially when dealing with properties which use an attribute to specify the use of a list. I looked at your source and found the following
Which lead, for example, to the corresponding DataTemplates in your source code.
I would like to be able to replace Mindscapes default editors by my own. I tried clearing the BuiltInEditorStyleCollection and putting my own editor styles to the collection but was unsuccessful (not sure if it's the right way to try and do it or I missed something). Thanks Oscar |
|
|
Hello, I may have found a way to do this. If I define a style for the PropertyGrid and set the property BuiltInEditorStyles with my own styles it seems to work.
Is this the correct way to do it? or is there a better way to do it? Thanks Oscar |
|
|
Hi Oscar, Yes, that is the correct way to override the default styles. -Jason Fauchelle |
|
|
Thanks Jason. A related question. How do I specify that I would like to use a specific editor control (i.e. MyDoubleEditor) for doubles but do it in such a way that I don't have to go to each instance I use the propertygrid and add the EditorType for double to the Editors list. Thanks Oscar |
|
|
Hi Oscar, You should be able to do this by setting the Editors property in a Style that you apply to all PropertyGrid instances. The downside of this is that setting the Editors property on an instance will overwrite what's set in the Style. If you don't set the Editors property on many instances, then this approach would be fine. If you do set the Editors property on most instances, then you'd need to add the editor to each of them. Hope that helps. -Jason Fauchelle |
|
|
Thanks Jason. I had to do things a bit differently. Please let me know your view on this approach. I tried setting the Editors property in my Style but I'm not allowed, something about "Writable property expected." What I ended up doing is having a new control derived from your propertygrid and creating a dependency property of type EditorCollection.
Then in the Style I can set the editors I want
Then on the loaded event of the propertygrid I add the custom editors to the Editors property. This allows me to keep existing editors and allows me to also add in XAML other editors to different instances of the propertygrid if required. Please let me know what you think. ...Oscar P.S. I moved the code to the Initialized event and it seems to speed the performance. |
|
|
Sorry about that Oscar, I should have checked the Editors property before suggesting to use it in a Style. I think that your solution is great. As you mentioned, this has the advantage of specifying default editors in the style, but still being able to add additional editors on specific PropertyGrid instances. -Jason Fauchelle |
|