How do I create a WPF rounded container that clips children?

前端 未结 1 1509
时光说笑
时光说笑 2021-01-19 22:11

The following piece of code is supposed to draw a menu bar inside a rounded container. You\'ll notice that the bottom is rounded, but the corners of the menu aren\'t. I fo

1条回答
  •  半阙折子戏
    2021-01-19 22:47

    Chris Cavanagh has a blog post about rounding controls. It should help you achieve what you want.

    Edit: Below is the code from that blog.

    
        
        
            
                
                
                
                
                    
                    
                        
                    
                    
                    
                    
                    
                    
                
            
        
    
    

    All it does is include a ‘mask’ Border element as a sibling of the content you want to clip. In the content it uses a VisualBrush bound to that mask. The mask will be automatically sized to your content, so it’s a nice "set and forget" solution

    0 讨论(0)
提交回复
热议问题