How do I make a WPF data template fill the entire width of the listbox?

后端 未结 8 1365
别跟我提以往
别跟我提以往 2020-12-04 16:23

I have a ListBox DataTemplate in WPF. I want one item to be tight against the left side of the ListBox and another item to be tight ag

8条回答
  •  无人及你
    2020-12-04 16:56

    If you want to use a Grid, then you need to change your ColumnDefinitions to be:

        
            
            
            
        
    

    If you don't need to use a Grid, then you could use a DockPanel:

        
            
                
                
                
                
            
            
            
        
    

    Notice the TextBlock at the end. Any control with no "DockPanel.Dock" defined will fill the remaining space.

提交回复
热议问题