How to stretch in width a WPF user control to its window?

后端 未结 7 1891
执念已碎
执念已碎 2021-01-31 14:52

I have a Window with my user control and I would like to make usercontrol width equals window width. How to do that?

The user control is a horizontal menu and contains a

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-31 15:19

    You need to make sure your usercontrol hasn't set it's width in the usercontrol's xaml file. Just delete the Width="..." from it and you're good to go!

    EDIT: This is the code I tested it with:

    SOUserAnswerTest.xaml:

    
        
            
                
                
                
            
            a
            b
            c
        
    
    

    Window1.xaml:

    
        
    
            
        
    
    

提交回复
热议问题