This project has moved. For the latest updates, please go here.

PropertyGrid EditorTemplateDefinitions as Resources

Feb 10, 2016 at 3:37 PM
If I create a set of EditorTemplateDefinitions in a resource dictionary how can I then assign them to instances of the PropertyGrid?

At the moment I can define the DataTemplate section as a resource and then use it like this:
        <xctk:PropertyGrid.EditorDefinitions>
            <xctk:EditorTemplateDefinition EditingTemplate="{StaticResource FlowrateDataTemplate}">
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type gcm:Flowrate}"/>
                </xctk:EditorTemplateDefinition.TargetProperties>
            </xctk:EditorTemplateDefinition>
        </xctk:PropertyGrid.EditorDefinitions>
But that separates the data template definition from the types to which it is applicable. Is there a way that I can define the whole EditorDefinition as a resource and then assign it something like:
        <xctk:PropertyGrid.EditorDefinitions>
            <xctk:EditorTemplateDefinition Content="{StaticResource FlowrateDataTemplate}" />
        </xctk:PropertyGrid.EditorDefinitions>
Thus keeping together the data template and the types to which it applies?

The only reason I having to do this is the Flowrate type is a struct and the usual expandable object approach doesn't work correctly due to it being a value type. See other discussions about why that is.