Skip to content

ComboBox incorrect behavior when using Items property #87

Closed

Description

@jeromelaban

Using this simple sample, the list is modified at each selection:

<ComboBox>
	<ComboBoxItem>Value 1</ComboBoxItem>
	<ComboBoxItem>Value 2</ComboBoxItem>
	<ComboBoxItem>Value 3</ComboBoxItem>
</ComboBox>

Observed with Uno.UI 1.31.0-dev.94.

Activity

  1. added
    kind/bug
    on Jul 2, 2018
  2. self-assigned this
    on Oct 5, 2018
  3. double28 commented on Oct 10, 2018

    @double28

    in android,the last selected item dispeared! in ios,no item show!

  4. leboeuf commented on Oct 11, 2018

    @leboeuf
    Contributor

    Here the items are of type ComboBoxItem, which is a view.
    Since views can only have one parent, when ComboBox.UpdateContentPresenter() sets its _contentPresenter.Content to the SelectedItem, the parent of the item becomes that ContentPresenter, which explains why it's not in the dropdown list anymore.

    One option would be to implement in Uno the specifics of CarouselPanel that make the dropdown expand around the selected item (if we want the same behavior as UWP).
    If you simply want to display strings in your ComboBox I suggest that you use the ItemsSource attribute instead of creating ComboBoxItems manually.

  5. double28 commented on Oct 17, 2018

    @double28

    In android,i can define a ItemTemplate of ComboBox,then the behaviour of ComboBox is well.
    In IOS, it's not work still! I define a List as the ItemsSource value,it's still show nothing.

    @jeromelaban ,do you know How to deal with it? Thank you!

  6. self-assigned this
    on Dec 13, 2018
  7. XiaotianNetlift commented on Dec 21, 2018

    @XiaotianNetlift
    Contributor

    If you need to set the choices in xaml, you can use the primitives literals as a temporary workaround:

    <ComboBox>
        <x:String>Red</x:String>
        <x:String>Green</x:String>
        <x:String>Blue</x:String>
    </ComboBox>
    

    Using a list for ItemsSource should work on both on ios & android. And, depending on what type of the list you get, you might need to set the DisplayMemberPath.

  8. self-assigned this
    on Jan 10, 2019
  9. added a commit that references this issue on Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions