I'm having difficulty with populating and showing the suggestions list of XLabs.Forms.Control:AutoCompleteView. I've already binded the observable collection in the ViewModel to the Suggestions property of the autocompleteview xaml.
According to my debug code (i.e. just a loop that writes the contents returned by a query to the debug output), my queries are returning items so i think the problem lies in just showing the said items.
Here's the code for the Xaml and ViewModel (the Store class has a StoreName property/field)
XAML
<ContentPage.Resources>
<ResourceDictionary>
<DataTemplate x:Key="SugestionItemTemplate">
<ViewCell Height="60">
<ViewCell.View>
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Label Text="{Binding StoreName}" VerticalOptions="Center" HorizontalOptions="Start" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout HorizontalOptions="Center" Spacing="10">
<StackLayout.BindingContext>
<vm:CreateSaleViewModel />
</StackLayout.BindingContext>
<Label Text="Store" />
<controls:AutoCompleteView Placeholder="Type a store"
SuggestionItemDataTemplate="{StaticResource SugestionItemTemplate}"
Text="{Binding StoreQuery}"
ShowSearchButton="True"
SearchBackgroundColor = "White"
SearchCommand ="{Binding SearchCmd}"
Suggestions="{Binding StoreSuggestions}" />
</StackLayout>
ViewModel
class CreateSaleViewModel
{
// Query Variables
public string StoreQuery { get; set; }
// Query Suggestions
public ObservableCollection<Store> StoreSuggestions { get; private set; }
public ICommand SearchCmd { get; set; }
public CreateSaleViewModel()
{
SearchCmd = new Command(Search);
}
private async void Search()
{
StoreSuggestions = await App.AzureDataStore.SearchStoresAsync(StoreQuery);
}
}