This is a migrated thread and some comments may be shown as answers.
Autocomplete bind differently on iOS and Android
2 Answers 41 Views
This is a migrated thread and some comments may be shown as answers.
Ivailo
Top achievements
Rank 1
Ivailo asked on 02 May 2017, 07:58 AM

Hi Guys, 

I am trying to use the Xamarin.Forms Autocomplete control but it is very strange that it works in different way on iOS 10.3 and Android 6.0

 

Actually, 
private void RadAutoComplete_SuggestionItemSelected(object sender, Telerik.XamarinForms.Input.AutoComplete.SuggestionItemSelectedEventArgs e)         { var dataItem =  e.DataItem;

        }

When I select an item from the autocomplete list on Android => e.DataItem is of the object type from the List which is my ItemsSource.
But when I select an item on iOS the e.DataItem is actually string with the value of the selected object. but not the whole object containing all other information in it ? How to fix this ?

<telerikInput:RadAutoComplete HorizontalOptions="FillAndExpand" BackgroundColor="Transparent" ItemsSource="{Binding AreaTypes}" WidthRequest="200" TextSearchPath="AreaType" Watermark="Search here..." SuggestionItemSelected="RadAutoComplete_SuggestionItemSelected" CompletionMode="Contains">

</telerikInput:RadAutoComplete>

2 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 05 May 2017, 07:57 AM
Hi Ivailo,

Indeed, providing a unified experience across platforms is one of the main purposes of the framework. We will include a fix in our next service release. For the time being, please use the following workaround:

private void AutoComplete_SuggestionItemSelected(object sender, Telerik.XamarinForms.Input.AutoComplete.SuggestionItemSelectedEventArgs e)
        {
            BusinessObject businessObject = e.DataItem as BusinessObject;
            if (businessObject == null)
            {
                RadAutoComplete autoComplete = (RadAutoComplete)sender;
                businessObject = autoComplete.FilteredItems.Cast<BusinessObject>().Where(obj => obj.Name == (string)e.DataItem).FirstOrDefault();
            }
        }
where BusinessObject would be your data item and Name would be the property name you use to search by.

Best regards,
Ves
Telerik by Progress
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
0
DAve
Top achievements
Rank 1
answered on 18 May 2017, 12:49 PM
thanks for information, i had same problem
Asked by
Ivailo
Top achievements
Rank 1
Answers by
Ves
Telerik team
DAve
Top achievements
Rank 1
Share this question
or