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

后端 未结 4 1823
醉梦人生
醉梦人生 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条回答
  •  梦毁少年i
    2021-01-29 23:03

    I was try many method here but can't solve my problem. (Fill other control in control)

    Until i found it

    
    //default
    //HorizontalAlignment="Stretch" 
    //VerticalAlignment="Stretch"
    

    Example:

    //UserControl:
    
    //Grid: 
    
    //Code: 
    Grid_test.Children.Add(UC_Test);
    

    For easy design

    
    //Code
    Grid_test.Children.Add(UC_Test);
    UC_Test.Width = Double.NaN;
    UC_Test.Height = Double.NaN;
    

提交回复
热议问题