Stretch empty WPF ListView to take the remaining space

后端 未结 2 1203
渐次进展
渐次进展 2021-02-06 22:23

I always have problems with a ListView inside a dynamic layout control like a Stackpanel.

Right now I have a Window with a Stackpanel as Root-Control. The Stackpanel str

2条回答
  •  隐瞒了意图╮
    2021-02-06 23:14

    This has nothing to do with the ListView. It is the StackPanel's "fault". In a StackPanel the child items always consume only the space they need (in the direction of the orientation of the StackPanel). That's how the StackPanel is designed. Use a DockPanel instead, there you can make the last item fill up all the space that is left over using LastChildFill="true" (true is default, so no need to explicity specify it).

    
        
        
            
                
                    
                
            
             
    
    

提交回复
热议问题