Skip to content

Dropdown Binding automatic updates upon list changes #22

@marijneken

Description

@marijneken

In Unity-Weld-Examples, there is one Dropdown example. The example shows how to connect to a simple string[] array in the view model, but that only updates the list once upon initialization.

I'm having a hard time figuring out how to bind to a list so it will automatically update upon changes in that list. The example uses a simple string[] as the type, but I noticed that there are classes like ObservableList and BoundObservableList. So I thought I could maybe use those types of lists instead, but no luck. Simply making the string[] array property a [Binding] and doing a call to OnPropertyChanged("MyList") when the list is changed, seems to have no effect.

I looked at the code of DropdownBinding, but couldn't figure out if and how it could be done. I feel like I'm missing something really obvious here, so that's why I thought it's probably best to ask you.

On a side note: I'm using this to link to items from a database, so I'd like to use the ID of those items as the actual value that is used as the Selection value. I'm pretty sure that could be done by using the "Selection View Model To UI Adapter", "Selection UI To View Model Adapter" and "Options Adapter" settings. So hopefully a solution exists where I could solve both of these "problems" at the same time. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions