Highlight whole TreeViewItem line in WPF

前端 未结 9 707
暗喜
暗喜 2020-11-30 17:48

If I set TreeViewItem Background it highlights the header only. How can I highlight the whole line?

I have found a post almost solving a problem http://social.msdn.

9条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 18:28

    For a XAML only approach I've taken one of Bendewey's solutions and broken it up a bit into a more basic solution:

    The style below should allow Treeview items to span:

    
    

    In order to get it to operate and collapse like a proper Treeview the below triggers should allow this:

                                              
                        
                            
                                
                                
                                                        
                        
                        
                            
                                
                                
                                                      
                                                
                        
                            
                                
                                
                                                                         
                        
                        
                                                       
                        
                        
                            
                        
                        
                            
                        
     
    

    Just nest the triggers within the Control Template. Colours/padding/design will need to be tweaked to suit your own needs but the above should be a very basic idea on a XAML only foundation.

提交回复
热议问题