I would like to show all distinct Category in a ComboBox named categoryList
<DataTemplate x:Key="CategoryTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Category}"/>
</StackPanel>
</DataTemplate>
...
<ComboBox Name="catagoryList" VerticalAlignment="Top" SelectionChanged="categoryList_SelectionChanged" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" ItemTemplate="{StaticResource CategoryTemplate}"/>
...
code behind:
this.categoryList.DataContext = ldc.Books.Select(b => b.Category).Distinct();
but, its not working. How can i do this? Or is there any other way to do that? Thank you.