1
votes

Probably this is a very stupid question, but I am not able to find a solution. I would like to bind the ComboBox Text property to the property of my items which are bind in ItemsSource. The problem is that I need to achieve this without the usage of DisplayMemberPath. So I am simply using the Path for Binding but this do not work:

<ComboBox IsEditable="True"
          ItemsSource="{Binding MyItemsCollection}"
          SelectedItem="{Binding MySelectedItem, Mode=TwoWay}"
          Text="{Binding Path=MyProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

In this case I have the .NET type name displayed instead of the value of MyProperty property.

I do not want to override the ToString in my type.

Thank you for help.

1

1 Answers

1
votes

You should override ToString method in the class that you binding to ComboBox.

public class YourClass
{        
    public override string ToString()
    {
        return DisplayPropName;
    }
}