DropDown DataStore and Binding

Hi everyone,

I am reaaly stuck in altough I tried in examples and forum discussion suggestions about this topic. I have a list that has some objects that objects keeps other objects inside of it and many properties on it.

private void InitializeComponents()
{
    myObjectDropDown = new DropDown()
    {
        DataStore = Controller.MyObjects, // this is dynamic list it can be updated in different ways in plugin
        ItemKeyBinding = Binding.Delegate<MyObject, string>(obj => obj.GetGuid.ToString()),
        ItemTextBinding = Binding.Delegate<MyObject, string>(obj => obj.Name),
    }
}

I am trying to catch objects by binding. but DataStore don’t catch MyObjects list. Even if I change the signature of this list to FilterCollection<IMyObject> (interface of object).

Then I realized when I changed IMyObject to MyObject which is concrete one, DataStore catches it in first time but when I contunie to debugging with other initializations its disappear automatically.

  • Can DataStore keeps abstract (interfaces) objects?
  • What is the relation between DataStore — > ItemKeyBinding, ItemTextBinding ?

Thanks in advance,
-Oğuzhan

@curtisw - is this something you can help with?

In some ways I’m glad to see I’m not the only one hitting my head against dropdowns.

The DataStore can point towards collections of interfaces, it works with an ItemListCollection which holds IListItem's not the concrete implementation of ListItem.
The ItemKey and ItemText Bindings tell the drop down how to go from an item in you list to the Key and Text properties. I’ve had success using Property Bindings.
As an example of how I’ve set these up:

ItemKeyBinding = Binding.Property((IMyObject obj) => obj.GetGuid.ToString()),
ItemTextBinding = Binding.Property((IMyObject obj) => obj.Name)

I’ve attached a file demonstrating it with the ListItemCollection, nevermind the GridView, I wrote that part to demonstrate a different weird behavior that I posted about this morning. The key part demonstrating a dropdown using bindings is the region from line 86 to line 104
ExampleDropDownPanel.cs (6.3 KB)

Hope this helps!

Hi @cullen.sarles,

Sometimes it is really hard to understand logic because lack of Eto.Forms documentation and examples, so thanks for your example!