Different template for items in ComboBox's drop-down list and for selected item

前端 未结 2 1236
刺人心
刺人心 2020-12-09 11:01

I have a ComboBox with fairly complex template for individual items, which includes two images and several lines of text:

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 11:40

    The selected item (in the ComboBox itself, not the dropdown) is not inside a ComboBoxItem so you can do something like this:

    
        
            
                
                    
                
            
        
    
    

    (Edit: Note that the binding in the for the selection box will throw errors because the RelativeSource is not found. There are various options of circumventing this, one being a custom value converter that returns true or false depending on whether the ancestor exists (manual tree walking).)

提交回复
热议问题