this is the Book class Book{BookId, Title, Category, Quantity}; So, how would i select only one object from each category using linq query? i tryed like this,
this.catagoryList.DataContext = ldc.Books.Distinct(); //categoryList is a ComboBox
but you know it doesn't work. All of these objects are unique, so it shows same category for many time. Actually i want it like GroupBy, but i would like to select only one objects from each group to show unique categories in the ComboBox. Thanks.
XAML:
<DataTemplate x:Key="CatagoryTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Catagory}"/>
</StackPanel>
</DataTemplate>
...
<ComboBox Name="catagoryList" ItemsSource="{Binding}" ItemTemplate="{StaticResource CatagoryTemplate}" SelectionChanged="catagoryList_SelectionChanged" IsSynchronizedWithCurrentItem="True"/>
...