1

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.

0

1 Answer 1

1

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

public class YourClass
{        
    public override string ToString()
    {
        return DisplayPropName;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.