How do I make an ItemsControl stretch to fill all availible space?

后端 未结 4 359
青春惊慌失措
青春惊慌失措 2021-01-19 17:02

I have an ItemsControl, with its ItemsSource bound to a list of items. The size of each of the items is as small as they can be, what I need is for the control and the items

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-19 17:27

    I think this ought to work, depending on what contains the outermost Grid.

    By default, a Grid will stretch to fill its container, and it'll cause its contents to stretch to fill itself. If you're putting the ItemsControl in a DockPanel and setting DockPanel.Dock="Bottom" on the ItemsControl, it'll fill the bottom of the DockPanel, so if I understand correctly, that's not what you want.

    
        
            
                
            
        
    
    

    Grid is kind of the Swiss Army boat anchor of XAML layout. Throw 'em around everywhere.

    If you want to dock other stuff in a DockPanel, here's a simple DockPanel layout:

    
        
            
        
        
            
                
                    
                
                
                    
                    
                
            
        
    
    

提交回复
热议问题