0
votes

I am using the Extended WPF Toolkit for their property editor. http://wpftoolkit.codeplex.com/wikipage?title=PropertyGrid

I have a few StringCollection objects defined in my settings file that are being shown as System.Collections.Specialized.StringCollection rather than in a CollectionEditor.

Here is how I defined the property editor:

<xctk:PropertyGrid x:Name="SettingsGrid" SelectedObject="{Binding Source={x:Static properties:Settings.Default}}" IsCategorized="False">
</xctk:PropertyGrid>

is there additional setup required?

1
You may perhaps need to define a TypeConverter for the same, or add properties manually to the PropertyGrid instead of being auto generated. - pushpraj

1 Answers

1
votes

here is a sample for specifying custom editor for System.Collections.Specialized.StringCollection in PropertyGrid

<xctk:PropertyGrid x:Name="SettingsGrid"
                   SelectedObject="{Binding Source={x:Static properties:Settings.Default}}"
                   IsCategorized="False"
                   xmlns:sp="clr-namespace:System.Collections.Specialized;assembly=System">
    <xctk:PropertyGrid.EditorDefinitions>
        <xctk:EditorTemplateDefinition TargetProperties="{x:Type sp:StringCollection}">
            <xctk:EditorTemplateDefinition.EditingTemplate>
                <DataTemplate>
                    <Expander Header="(StringCollection)">
                        <ListBox ItemsSource="{Binding Value}"
                                 HorizontalContentAlignment="Stretch">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Path=.}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Expander>
                </DataTemplate>
            </xctk:EditorTemplateDefinition.EditingTemplate>
        </xctk:EditorTemplateDefinition>
    </xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>

before specifying the editor

before

after specifying the editor

after

this sample may not be exactly demonstrating how you want to edit the collection, you may adjust the template as needed