This is a migrated thread and some comments may be shown as answers.

SelectedItem not bindable + Pre-Selecting

1 Answer 75 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
schlabo
Top achievements
Rank 1
schlabo asked on 17 May 2015, 10:40 AM

It seems that in the Universal UI variant of the Telerik UI (2015.1.420.45, currently working on the WinRT Windows Phone 8.1 part), "SelectedItem" can not be used for binding. Apparently, the property "SelectedItem" does not have an accessible setter. When searching for the control, it seems that other variants (e.g., WPF) of the control do allow binding to the SelectedItem.

How to access the selected item via a binding from the ViewModel then, without writing some event-based code in the code behind file?

The tasks I'd need to do is:

1. Pre-set an item in the auto complete box (Two-Way binding) for the default value.

2. Get the selected item out of the auto complete box when the user is finished with the data entry form on the page.

My current workaround is to send the RadAutoCompleteBox as command parameter, to access its SelectedItem in the view model. But of course, it's not a good solution to work with the RadAutoCompleteBox control in the ViewModel. But switching to events and starting to use the code behind file isn't too much better. And for both workarounds, pre-selecting a value seems to be difficult.

Thanks!
Andreas

1 Answer, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 20 May 2015, 03:32 PM
Hi Andreas,

Thank you for contacting us! Selected item represents the selected item from the autocomplete while the dropdown is active. In this scenario I can suggest using Text property instead as it represents the actual value that user has selected. 

If the scenario cannot be achieved with the current API in MVVM we can consider opening the API to make it easier to use.

Let me know if this makes sense.

Regards,
Tsvyatko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AutoCompleteBox
Asked by
schlabo
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Share this question
or