How to use DockStyle.Fill for standard controls in WPF?

后端 未结 4 1830
醉梦人生
醉梦人生 2021-01-29 22:17

I\'m used from windows forms, that I create a panel, place controls inside it and give them DockStyle.Fill to max out their size to the surrounding panel.

I

4条回答
  •  一个人的身影
    2021-01-29 22:49

    just wrap your controls in a grid with two rows. The grid will automatically use all space given to it and you can define the rows to take up all space left by giving them a height of "*". The first row in my example (Height="Auto") will take as much space as needed by the ribbon. Hope that helps.

    
      
        
        
      
    
      
    
      
    
    

    By adding the "Grid.Row=.." attribute to child controls of the grid they get assigned to rows of the grid. Then the grid will size it's children as defined by the row definitions.

提交回复
热议问题