views:

62

answers:

2

Hi there

In a given binding is it possible to specify the path on the source object? Seems like this could a void a lot of trivial converters..

Imagine this..:

class foo
{
   bool A
   int B
}


<ComboBox  ItemsSource="ListOfFoos" SelectedItem="{Binding number, SourcePath=B}"   />
A: 

Hi there,

I guess the SelectedValuePath property is what you are looking for. It's inherited from Selector, so it will work for ComboBoxes, ListBoxes, etc.

Cheers, Alex

alexander.biskop
A: 

2 options:

  1. DisplayMemberPath="B" property of ComboBox
  2. Custom template for each item

like this:

<ComboBox.ItemTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding B}"/>
    </DataTemplate>
</ComboBox.ItemTemplate>
repka