i am creating a Eto.Forms.ListBox which uses a DataStore for its list items as shown here. However my list is not a list of strings but a list of class instances. The class name is “Fruit”. The listbox DataStore seems to accept my list but each list item is displayed in the listbox like this:
<__main__.Fruit instance at 0x0000000000000085>
Each class instance has a property “Name”. How do i tell Eto to use “Name” as Eto.Forms.ListItem.Text ?
sorry no, it still displays list items like this using a Text property:
The ToString() hint i’ve googled as well and found that i can change how a class instance is printed using __repr__ (which is problably equal to the ToString() solution) and it then shows the ListBox items using that text output. A better way i’ve found was to manually set the ListBoxItem.Text and attach the class instance as Tag to the ListBoxItem…
Is it a bug that i cannot set a DisplayMember like in WinForms ?
In C#, you’d set the data store to some view model and then you’d bind the appropriate property to the list box’s ItemTextBinding member. I’m pondering how to do this in Python.