简体   繁体   中英

Extended WPF Toolkit not showing String Collection in collection editor

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?

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

之前

after specifying the editor

后

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM