I tried first dynamically but I guessed that it doesnt work because I experienced from sfrotator. Then i tried like in the documentation. I wrote exactly same code but no chance. Here is my code how I tried it
In xaml I defined AutoComlete as below with the Datasource binding and Name as DisplayMemberPath
<autocomplete:SfAutoComplete x:Name="autocomplete" Watermark="Enter a name" MinimumPrefixCharacters="3" MaximumDropDownHeight="200"
AutoCompleteMode="Suggest" SuggestionMode="Contains" DataSource="{Binding AllItems}" HeightRequest="60"
SelectedValuePath="Id" DisplayMemberPath="Name">
</autocomplete:SfAutoComplete>
In my View Model and its constructor, I get all the items;
public class ItemsViewModel
public ItemsViewModel()
{
var Items = await db.getAllItemsAsync(recursive: false);
AllItems = new ObservableCollection<ItemList>(Items));
RaisePropertyChanged("AllItems");
return cacheItems;
}
}
Then I assign BindingContext in the constructor of the page but it doesnt unfortunately work. I tried using ItemItemSource binding as well but it doesnt work
autocomplete.BindingContext = new ItemsViewModel();
my Model
public class Item
{
[PrimaryKey, AutoIncrement, Unique, NotNull]
public int Id { get; set; }
[MaxLength(255)]
public string Name { get; set; }
}
I checked your sample app called "SampleBrowser-Forms" but there example is based on String list not with object list. What am I doing wrong?