WPF binding Width to Parent.Width*0.3

后端 未结 2 1386
遇见更好的自我
遇见更好的自我 2020-12-30 11:23

I want to bind a control\'s Width to the parent\'s Width, but to a certain scale. Is there a way to do something like this:



        
2条回答
  •  梦毁少年i
    2020-12-30 11:36

    I'd recommend simply doing this in XAML using a grid columns and the * width type:

    
        
            
                
                
            
    
            
             
    
        
    
    

    You can change the ratio of how much the columns take up by changing the numbers before the * in the column widths. Here it's setup as 1 and 2, so the grid will be split in 3 (sum of all * widths), with 1/3 of width to first column and 2/3 to second column.

提交回复
热议问题