문제

I am using the AutoCompleteBox in WPF, I populate the suggestions with a List that consists of four fields. When the user selects an item and I reach my eventHandler, i can see that

MyAutoCompleteBox.SelectedItem

is an object that has my four values, if i hover this text in the debugger i can see the four values listed, however i don't know how to access these values in the code.

I tried

List<Codes> selected = MyAutoCompleteBox.SelectedItem as List<Codes>;

where Codes is my List. selected returns as null and empty every time. Is there a way to get to these values? Thanks!

도움이 되었습니까?

해결책

Can you try:

Codes selected = MyAutoCompleteBox.SelectedItem as Codes;

or

Codes[] selected = MyAutoCompleteBox.SelectedItem as Codes[];

다른 팁

If you want the listing of items used as the backing collection for the AutoCompleteBox try...AutoCompleteBox.ItemsSource.

It means that you cannot convert whatever MyAutoCompleteBox.SelectedItem is to a List.

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