This project has moved and is read-only. For the latest updates, please go here.

How to customize the list displayed in the left-hand of a CollectionControl editor ?

Apr 5, 2016 at 10:47 AM
Edited Apr 6, 2016 at 8:35 AM
In my CollectionControlDialog editor, for the list on the left, I would like to display not the type of the object ("Person") but a property of the object.
For example, the "FirstName" of the Person as i can see in your documentation.

Is it possible to put a property instead of the type's name ?
In the list on the left side, instead of "Person, Person, Person, ...", can i have "Brian, Paul, ..."

https://wpftoolkit.codeplex.com/wikipage?title=CollectionControl&referringTitle=Home

I used the Extented WPF Toolkit 1.9.0
Developer
Apr 6, 2016 at 1:46 PM
Hi,
Yes you can.
Simply override the ToString() method to display the property you wish :
public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }

    private void Button_Click( object sender, RoutedEventArgs e )
    {
      var dialog = new CollectionControlDialog( typeof( Person ), new List<Type>() { typeof( Person ) } );
      dialog.ItemsSource = new List<Person>() { new Person() { FirstName = "Tom", LastName = "Smith", Age = 35 } }; 
      dialog.Show();
    }
  }

  public class Person
  {
    public Person()
    {
    }

    public string FirstName
    {
      get;
      set;
    }
    public string LastName
    {
      get;
      set;
    }
    public int Age
    {
      get;
      set;
    }

    public override string ToString()
    {
      return this.FirstName;
    }
  }
But this will work in v2.1 and up.
Also, if you change a property that is used in the ToString() method, if you wish to see the update in the left ListBox, you will need v3.0 and up

Please note that the current version for the
  • Plus users is : v3.0
  • Community users is : v2.6 (v2.7 will soon be released)
Apr 7, 2016 at 1:41 PM
Thanks a lot for your reply.
I am going to update my version of Extented WPF Toolkit to v2.6 (current version)

And about the fix you are talking in v3.0, it is for the Plus edition, and for the Community edition, when it will be fixed ?
Developer
Apr 7, 2016 at 2:16 PM
The Plus Edition is always 2 or 3 versions ahead. You can take a look at it here : http://wpftoolkit.codeplex.com/wikipage?title=Compare%20Editions
or wait for v3.0 to be released.
Current versions are :
Plus Edition v3.0
Community Edition : v2.7.