WPF IsEditable=true ComboBox filled with objects displays the ToString() as the selected item

前端 未结 2 1909
遥遥无期
遥遥无期 2020-12-01 14:34

The Wpf combo box allows editing, and this is fine if all your combo box items are strings, or have a ToString() method defined on them.

When you select an item, it

2条回答
  •  既然无缘
    2020-12-01 15:16

    You can do this entirely within Xaml

    
        
            
                
            
         
    
    

    The upside is that you can define and change this however you want in your XAML without any code-behind. You bind the ItemsSource to your collection of objects, and then you set the path on which to base your search to TextSearch.TextPath. Then, within you custom ItemTemplate you can bind the TextBlock to something else outside of the object's ToString method.

提交回复
热议问题