문제

I have an autocomplete box where I am trying to bind the selected item to a propery of the item that is actually selected. I.e. I have a Client object with a Name property, and the ItemsSource of my autocomplete box is a List of Clients.

The property I am trying to bind as the selected Item is a String, called SelectedClientName. But because SelectedClientName is not of type Client, I cannot bind it directly.

As a work around, I am using a converter. But I would like to know if there is a way to do this in the binding without converters.

도움이 되었습니까?

해결책

I'd suggest having SelectedClientName not be of a different type, in your case of type string. Keep it the Client type and utilize your Name property where a string is required.

Here's some additional information on binding to complex objects in an AutoCompleteBox: http://www.codeproject.com/Tips/79158/AutoCompleteBox-Binding-Custom-Objects

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top