How to Stretch WPF Tab Item Headers to Parent Control Width

后端 未结 11 1950
花落未央
花落未央 2020-11-29 23:17

Is there a way in XAML to cause the tab item headers to stretch across the width of the tab control?

For example, I have three tabs: red, blue and green. If I have a

11条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 23:56

    Here is a painless solution that uses Templates only:

    
        
            
                
                                            
                                        
                                        
                                            
                                        
                                    
                                
                                
                                    
                                        
                                        
                                        
                                        
                                    
                                    
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                    
                                    
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                    
                                    
                                        
                                            
                                                
                                            
                                        
                                    
                                
                            
                        
                    
                
                
            
            
                
                    
                    
                    
                
            
            
                
                    
                    
                    
                
            
        
    
    

    Hope I've included all colors and it will work for you. Ahh... Snap! My Desaturation Effect! My WPF startup project you can grab that effect from there if you want (It's easier to plop the effect in trigger, than to recolor all the thing, same with highlights). Yes, that's a lot of code, but I simply changed ItemsContainer to look better and replaced standard Header control with UniformGrid and set Rows or Columns to 1 depending on TabStripPlacement. Now I can collapse this code, or hide it somewhere. :)

提交回复
热议问题