Maybe a simple task but I can’t find the solution. I have a combobox connected to a database. Instead of displaying the content of ProductLookup I just want to display the words ‘male’ and ‘female’ on the popup menu.
Thank you
<ComboBox Height="23" Name="ComboBox2" Width="120" IsEditable="False"
ItemsSource="{Binding Source={StaticResource ProductLookup}}"
SelectedValue="{Binding Path=ProductID}"
SelectedValuePath="ProductID"
DisplayMemberPath="Name"/>
Write a
Converterthat takes one of your “Product” objects….looks at the gender related data inside it, or does the gender determining logic, and then returns the gender string, “male” or “female”.Then use it in your XAML to set the
TextBlock:Alternatively you could provide a ViewModel which wraps your Product object, which has a specific property that indicates the “genderness” of the Product…then create a collection of those objects for setting in your ComboBox…then you can use
DisplayMemberPathto point to that property.