Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

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

$
0
0
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)

Viewing all articles
Browse latest Browse all 2157

Trending Articles



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