Search code examples
uwptelerik

What's the recommended way of setting the SelectedItem of a Telerik RadAutoCompleteBox programmatically in UWP


RadAutoCompleteBox's SelectedItem property has a private setter. What's the reason and how can I set the SelectedItem in a reliable way? Say I want to load a form containing user data from the database, how can I select the item that's specified in the database?

I searched the official documentation and couldn't find anything related to that there.


Solution

  • For the AutoCompleteBox you set the Text property instead of the SelectedItem. This is because ultimately the value of the control's selection is a string.

    For example, instead of doing something like:

    acb.SelectedItem = myItem;
    

    do this:

    acb.Text = myItem.StringProperty;
    

    If you need business object based selection instead of Text, ComboBox is a more appropriate control.