How to create WPF usercontrol which contains placeholders for later usage

前端 未结 2 1607
刺人心
刺人心 2020-12-13 00:22

I\'d better ask the question by example. Let\'s say I have UserControl and Window which uses this control.

I would like to design this control (named MyControl) in s

2条回答
  •  萌比男神i
    2020-12-13 00:54

    I think you want to set your UserControl's ControlTemplate with a ContentPresenter located inside (so you can define where the Content will be presented).

    Your Custom UserControl:

    
        
            
                
                    
                    
                    
                
            
        
    
    

    Usage:

    
        
            
                

    enter image description here

    If you need multiple items in your content section, simply place them in a container like a grid or a stackpanel:

    
        
            

提交回复
热议问题