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

New Post: PropertyGrid Collection Editor - Class types for new objects

$
0
0
Hi,

You can use an EditorTemplateDefinition to specify which editor a property will get :
<Window.Resources>
      <local:Holder x:Key="myListOfTypes" />
   </Window.Resources>
    
   <Grid>
      <Grid>
         <StackPanel>
            <xctk:PropertyGrid x:Name="_propertyGrid">
               <xctk:PropertyGrid.EditorDefinitions>
                  <xctk:EditorTemplateDefinition TargetProperties="Outline">
                     <xctk:EditorTemplateDefinition.EditingTemplate>
                        <DataTemplate>
                           <xctk:CollectionControlButton ItemsSource="{Binding Value}"
                                                         NewItemTypes="{Binding Source={StaticResource myListOfTypes}, Path=Types}"/>
                        </DataTemplate>
                     </xctk:EditorTemplateDefinition.EditingTemplate>
                  </xctk:EditorTemplateDefinition>
               </xctk:PropertyGrid.EditorDefinitions>
            </xctk:PropertyGrid>
         </StackPanel>
      </Grid>
   </Grid>

public class Holder
  {
    public List<Type> Types
    {
      get;
      set;
    }

    public Holder()
    {
      Types = new List<Type>();
      Types.Add( typeof( MyCircle ) );
      Types.Add( typeof( MyRectangle ) );
    }
  }

Viewing all articles
Browse latest Browse all 4964


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