Expandable Collections

Aug 11, 2010 at 4:58 PM
Edited Aug 11, 2010 at 11:38 PM
I've just started using this. Is there a way to get collections (Lists specifically) to expand to show their members? The only thing that shows up is the List type "System.Collections.Generic.List`1[System.Int32]"

Here is example of what I'm trying to do.

public class Foo
 public Foo()
   X = 3.14f;
   Y = 1.29f;

   IntList = new List<int>();

  public float X { get; set; }
  public float Y { get; set; }

   public List<int> IntList { get; set; }

 public class Bar
  public Bar()
   F = new Foo();
   B = true;

 public Foo F { get; set; }
 public bool B { get; set; }

 Bar myBar;

 private void button_Click(object sender, RoutedEventArgs e)
  myBar = new Bar();
  myGrid.Instance = myBar;
Aug 12, 2010 at 11:30 PM
Edited Aug 13, 2010 at 8:43 PM

Still looking at this - looks like the IList datatemplate just shows the string - looking at how to expand functionality...

Actually - I don't think it is getting hit - if I replace ListBox with a TextBox, that says "Hello" nothing changes...


    <DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId={x:Type clr3:ObservableCollection}}">
        <!--<ListBox ItemsSource="{Binding Path=Value}"/>-->

Mar 15, 2011 at 10:01 AM

I want a DataTemplate for ObservableCollection in there is a Button in their.


But their always come a mistake that it doesn´t find ObservableCollection.

<DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId={x:Type clr3:ObservableCollection}}">
      <Button Content="..."/>

What is my mistake?

Mar 15, 2011 at 11:17 AM
Edited Mar 15, 2011 at 11:17 AM

Datatemplates for generic Types normaly don't work.


Look at PropertyTemplateSelector.cs with the Line 

if (!(property.PropertyType is String) && property.PropertyType is IEnumerable)                
 propertyType = typeof(List<object>);

I added support for the

     <DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId={x:Type generics:List`1[System.Object]}}">
<TypeEditors:CollectionEditorControl NumerableType="{Binding Path=PropertyType}" NumerableValue="{Binding Path=Value}" MyProperty="{Binding}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></TypeEditors:CollectionEditorControl>