C1MultiSelect CombBox dropdown list not updating when ItemsSource changed

Posted by: msloan on 5 July 2018, 12:43 am EST

    • Post Options:
    • Link

    Posted 5 July 2018, 12:43 am EST

    Hi,

    I’m using a C1MultiSelect is display list of objects of type:

    
        /// <summary>
        /// Class to hold all the ComboBox items and ID
        /// </summary>
        public class ComboEntity
        {
            public int ID { get; set; }
            public string Title { get; set; }
        }
    
    

    When I bind a list of ComboEntity, I’m using:

    
    
    	    List<ComboEntity> M_lstUserListEntries = new List<ComboEntity>();
    
    	    // Fill M_lstUserListEntries with some entries
    
                M_cmbUserList.ItemsSource = M_lstUserListEntries;
                M_cmbUserList.DisplayMemberPath = "Title";
                M_cmbUserList.SelectedValuePath = "Title";
    
    	    // Here Dropdown List is correct
    
    	    // Fill M_lstUserListEntries with different entries
    
                M_cmbUserList.ItemsSource = M_lstUserListEntries;
                M_cmbUserList.DisplayMemberPath = "Title";
                M_cmbUserList.SelectedValuePath = "Title";
    
    	    // Here Dropdown List is NOT correct
    
    
    

    However when I change the contents of M_lstUserListEntries and update the C1MultiSelect control’s Item Source, I am finding the drop-down list contains the values from the PREVIOUS list. If I then select an entry from this dropdown, the text in the Combo is change to the corresponding string from the NEW list.

    Is there something I need to do to update the Dropdown list if the ItemsSource changes?

    Regards,

    Mark Sloan

  • Posted 5 July 2018, 10:27 pm EST

    Hi Mark,

    I do not observe the same behavior at my end. See attached screen-shots.

    public MainWindow()
            {
                InitializeComponent();
                {
                    List<ComboEntity> M_lstUserListEntries = new List<ComboEntity>();
    
                    // Filling M_lstUserListEntries with some entries
                    for (int i = 1; i < 11; i++)
                        M_lstUserListEntries.Add(new ComboEntity() { ID = i, Title = "Title" + i.ToString() });
    
                    M_cmbUserList.ItemsSource = M_lstUserListEntries;
                    M_cmbUserList.DisplayMemberPath = "Title";
                    M_cmbUserList.SelectedValuePath = "Title";
    
                    // Filling M_lstUserListEntries with different entries, so clearing the collection first
                    M_lstUserListEntries.Clear();
                    for (int i = 1; i < 11; i++)
                        M_lstUserListEntries.Add(new ComboEntity() { ID = i, Title = "NewTitle" + i.ToString() 	 
    });
                    //No need of following statements
                    //M_cmbUserList.ItemsSource = M_lstUserListEntries;
                    //M_cmbUserList.DisplayMemberPath = "Title";
                    //M_cmbUserList.SelectedValuePath = "Title";
                }
            }
    ``` Please let me if I am missing anything here.
    ~Ruchir
    [zip filename="C1MultiSelect_DrpDwn.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-bd5528de-caea-4607-bf12-20b669a82d68.zip[/zip][img]https://gccontent.blob.core.windows.net/forum-uploads/file-0a7f982c-102b-4806-9e01-ede4717c92a3.png[/img]
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels