Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: ComboBox in CollectionControl

$
0
0
Hi yt2014,

You can try setting a DataTemplate for specific properties with the PropertyGrid.EditorDefinitions. In the PropertyGrid Default Editors example available in the LiveExplorer sample, define a DataTemplate for the 3 lists :
<xctk:PropertyGrid x:Name="_propertyGrid"
                         SelectedObject="{Binding}"
                         Width="450"
                         Margin="10,30,0,0">

         <xctk:PropertyGrid.EditorDefinitions>
            <xctk:EditorTemplateDefinition TargetProperties="ListOfInt32">
               <xctk:EditorTemplateDefinition.EditingTemplate>
                  <DataTemplate>
                     <ComboBox ItemsSource="{Binding Value}"/>
                  </DataTemplate>
               </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <xctk:EditorTemplateDefinition TargetProperties="ListOfPerson">
               <xctk:EditorTemplateDefinition.EditingTemplate>
                  <DataTemplate>
                     <ComboBox ItemsSource="{Binding Value}" />
                  </DataTemplate>
               </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <xctk:EditorTemplateDefinition TargetProperties="ListOfStrings">
               <xctk:EditorTemplateDefinition.EditingTemplate>
                  <DataTemplate>
                     <ComboBox ItemsSource="{Binding Value}" />
                  </DataTemplate>
               </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

         </xctk:PropertyGrid.EditorDefinitions>
      </xctk:PropertyGrid>
ComboBoxes will be used to display the content of the lists. For the Person's list, you can redefine the ToString method of the Person's class to make it show the name of the Persons:
 public class Person
    {
      public string Name { get; set; }

      public override string ToString()
      {
        return this.Name;
      }
    }

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>