WPF ComboBox ItemTemplate binding to string collection

I have a combobox in wpf that binds to a list. Everything works fine, but now for some reason I need to bind an element to a template. XAML for combo box

<ComboBox ItemsSource="{Binding Tracks}" SelectedItem="{Binding SelectedTrack}"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding **WhatShouldBeHere**}"></TextBlock> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> 

If my data source is a user collection, then the binding is simple. I just need to pass the name of the property from the user collection, but as the binding source is a list of strings, which should be required.

+7
c # data-binding wpf xaml combobox
source share
1 answer

It should be

 <TextBlock Text="{Binding}"/> 

which is equivalent

 <TextBlock Text="{Binding Path=.}"/> 

See the Remarks section of the Binding.Path MSDN page for more information .

+15
source share

All Articles