Controlling the TabControl active tab with a ComboBox

前端 未结 4 833
北海茫月
北海茫月 2021-01-20 00:32

What i am really trying to achieve is to full control the active TabItem by using the combobox as the navigation control.

Here is what ive got so far:



        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-20 00:45

    Building off of hughdbrown's answer, I found this post on MSDN that describes your problem as a bug. You can reproduce it with this XAML (which has the opposite problem as your XAML):

    
        
            
                foobar
            
            
                fizzbuzz
            
        
        
    
    

    As you can see the Length binding works fine except for in the dropdown, where it is going off the TabItem instead of the string inside.

    I'm not sure it's ideal for your purposes, but you can get around it by being a little less elegant and reproducing your headers in ComboBoxItems:

    
        
            
                
            
            
                
            
        
        
            TabItem1
            TabItem2
        
    
    

提交回复
热议问题