Multicolumn ListBox in WPF

前端 未结 3 2113
心在旅途
心在旅途 2020-12-14 17:30

I have 3 TextBoxes and 1 Button and want to enter each of the the TextBoxes data into a ListBox in separate columns.

3条回答
  •  醉酒成梦
    2020-12-14 17:57

    As Ray correctly points out, ListView will do the job. However if you're stuck with and/or want to use ListBox you can also use an ItemTemplate with Grid and set the Grid.IsSharedSizeScope property on the ListBox itself. For example:

    
        
            
                
                    
                        
                        
                        
                    
                    
                    
                    
                    
                    

    This is a neat trick which can also be applied to other cases where you have multiple instances of Grid (ie: one per ListBoxItem as per this case) and want to share a column.

    Best regards,

提交回复
热议问题