WPF ComboBox Multiple Columns

后端 未结 3 1712
孤街浪徒
孤街浪徒 2020-12-11 06:49

I am just wondering if there is a wpf combobox control that can contain multiple columns?

And if not, what XAML I need to use to achieve this?

I am just loo

3条回答
  •  渐次进展
    2020-12-11 07:09

    I know im late but this is how you do it in a simplified way, After the DataTemplate tag you can put anything depending on how you want your lay out to look like.

      
                            
                                
                                    
                                        
                                        
                                    
                                    
                                    
                                        
                                        
                                    
                                
                            
                        
    

    Result

    Sample Result

    Or Use a readonly property in your DataModel as shown on the code below and set your combobox DisplayMemberPath to DisplayMemberPath="CodeRate"

     public string ActivityCode { get; set; }
     public string Rate { get; set; }
     public string CodeRate => string.Format("Code: {0} | Rate: 
     {1}",ActivityCode,Rate);
    

提交回复
热议问题