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
|
Hi! I wonder if there is a way to define Propertygrid.Editors in a style, stored in a separate file. The reason is that I have two propertygrids in my application and have to list the same editors twice in the main XAMl file. Thank you in advance!
|
|
|
Hmm, I don't think this is possible -- one of the limitations of WPF styling is that you can only use it to set a value, not to add to a collection. (Also, Editors isn't a dependency property, and a property must be a DP to be styled.) We addressed this for BuiltInEditorStyles by making the collection property read-write, but that was a breaking change, and we'd be reluctant to make a breaking change to something as widely used as the Editors property. It would however probably be possible to create your own EditorStyleablePropertyGrid by deriving from PropertyGrid and defining an additional read-write dependency property of type EditorCollection. In the change handler for this property, clear the real Editors collection and add the editors from the new collection: public EditorCollection MoBetterEditors Then you could set the MoBetterEditors property in a style, and it would be propagated to the real Editors collection. Obviously some discipline would be required not to use both Editors and MoBetterEditors on the same grid instance. Please note I haven't tried this out, so some experimentation may be required. |
|
|
Hi Ivan, Thank you, I've tried you solution and it works perfectly. Just a single check for the null value is required in private void OnMoBetterEditorsChanged such that: if (MoBetterEditors!=null) {
} Sincerely, Ilia |
|