CheckComboBox : How to prevent a combobox from closing after a selection is clicked?

后端 未结 2 1396
悲&欢浪女
悲&欢浪女 2021-01-01 05:32

I\'ve got a combobox and it\'s populated with a bunch of checkboxes. I wish the user to be able to click multiple times before the combobox closes (or is closed by the user

2条回答
  •  悲哀的现实
    2021-01-01 05:57

    Using Exapander Control you can achieve multple item selection without closing popup after single selection.

    For understanding please run this code separately.

    xaml

      
        
            
                
                    
                    
                
                
                
                
                
            
            
                
                    
                    
                
                
                    
                    
                
                
                    
                    
                
                
                    
                    
                
            
        
    
        
    
        
                
            
        
    
        
                
            
        
    
    
    
        
            
                
                    
                        
                            
                        
                    
                    
                        
                            
                        
                    
                
            
            
                
                    
                        
                            
                        
                    
                
            
        
    
    

    c# code

      public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();          
            ObservableCollection custdata = new ObservableCollection();
            custdata.Add(new Customer() { ContentData = "content1" });
            custdata.Add(new Customer() { ContentData = "content2" });
            custdata.Add(new Customer() { ContentData = "content3" });
            custdata.Add(new Customer() { ContentData = "content4" });
            custdata.Add(new Customer() { ContentData = "content5" });
            custdata.Add(new Customer() { ContentData = "content6" });
            lst.ItemsSource = custdata;
        }
    }
    public class Customer
    {
        public string ContentData { get; set; }
    }
    

    Result

    enter image description here

提交回复
热议问题