Xamarin.Forms Autocomplete CrossPlatform

2020-02-09 03:52发布

I am a newbie to Xamarin.Forms Platform. I hope you can help me in moving ahead. I want to have a control like autocomplete in xamarin.forms like below

Autocomplete

Can you please guide how can it be achievable in Xamarin.Forms? I want to achieve it with the Entry Control

TIA

7条回答
唯我独甜
2楼-- · 2020-02-09 04:12

You haven't included what exactly you want, just some sort of autocomplete.

I'll bullet point the Manual way to do it in general for a List of items:

  1. Use a TextBox to allow the user to input text.
  2. Use a List to gather all your objects together with their searchable property such as the object Name.
  3. As the user types something in the TextBox, the app should search in the List for the String entered in the TextBox.
  4. The suggestions should be displayed, according to the String value typed, in a ListView under the TextBox.
  5. User clicks on the ListView item, which is a suggestion, and then that autocompletes by taking the object Name from the item clicked on, to the TextBox.

A general way of doing autocomplete without the long rough procedure above is to use the Android AutoCompleteTextView.

You can still use the basic logic to do it in Xamarin Forms.

Look here for the AutoCompleteTextView for Android. Look here, here and here for help with AutoComplete in Xamarin Forms.

查看更多
爷、活的狠高调
3楼-- · 2020-02-09 04:14

I have a Xamarin.Forms custom control you can use that works with iOS, Android and UWP. It uses custom renderers to provide native UI under the covers. I built this because I didn't find any control that provided a good native experience and didn't change the height of the control when the dropdown opens. All the doc + reference to the NuGet package is available here: https://github.com/dotMorten/XamarinFormsControls/tree/master/AutoSuggestBox

查看更多
我想做一个坏孩纸
4楼-- · 2020-02-09 04:17

Please read these articles and try to implement solution on Xamarin.Forms using Custom Renderers.

Google Place API with Autocomplete in Xamarin Android

Xamarin.iOS Location Autocomplete by using Google Place API

查看更多
Animai°情兽
5楼-- · 2020-02-09 04:20

You can achieve this easily with SyncFusion AutoComplete plugin. This gives you various options to do rather than doing a custom render.

Reference: https://help.syncfusion.com/xamarin/sfautocomplete/getting-started

查看更多
该账号已被封号
6楼-- · 2020-02-09 04:27

I'm using this library SupportWidgetXF

It's cross platform.

查看更多
Root(大扎)
7楼-- · 2020-02-09 04:29

I tried to build my own suggestions/autocomplete following the answer of Imdad. I was hindered by my my criteria where that it had to be shown on top or expand when suggestions filled the listview. Not have a listview taking up space permanently.

You can try https://github.com/XamFormsExtended/Xfx.Controls But I experienced some issues with it. It displays on top

I experienced an issue where text in autocompleteview doesn't update from source binding or set from code behind with https://github.com/XLabs/Xamarin-Forms-Labs autocompleteview. That pushes away what is in the way temporarily to display suggestions

I personally went this solution https://github.com/dotMorten/XamarinFormsControls/tree/master/AutoSuggestBox

查看更多
登录 后发表回答